Monte Carlo simulations of globular cluster evolution. I. Method and test calculations