MOCASSIN: a fully three-dimensional Monte Carlo photoionization code