MCMC method to invert strong gravitational lenses