Monte Carlo modelling of relativistic runaway electrons and terrestrial gamma-ray flashes