The substrate in my tarantula tank is mouldy.

Your tank is probably too damp.  Increase ventilation to dry it out a little.  The mould is probably based around a scrap of food.  Remove all left over food items including chewed remains.  If this doesn’t work your substrate should be changed for one less prone to moulding (e.g. peat vermiculite mix, composted bark, quality coconut fibre).

My tank is full of small black flies.

If these flies run in a jerky motion they will be phorids.  These flies breed in decaying matter such as food scraps.  Remove all food leftovers and contemplate reducing the humidity of the tank.  They won’t attack living things (e.g. egg sacs), but might move in if the egg sac contents die for another reason.

If the flies don’t run in a jerky motion they are likely to be sclerids.  These mushroom flies breed in damp organic substrates.  They won’t harm your spider, but can be controlled by hanging sticky yellow traps in the spider room.

 My tank is full of mites.

These are probably house dust mites and won’t be a problem unless they reach plague proportions.  If they do, change the substrate and reduce the tank’s humidity.

My spider has mites on it.

They will probably be parasitic mites.  Wild caught tarantulas occasionally have small, white mites running all over them.  They don’t appear to persist in captivity and will die out naturally.

Captive bred spiderlings occasional pick up brown parasitic mites from their substrate.  Sterilize such substrates in a microwave oven to prevent future infestations (the heat will kill the mite eggs).  They can be picked off with forceps, but this tricky procedure carries risks to the spiderling.  Frequent sterile substrate changes will eliminate these mites.