Simulation of photon-nucleon interactions Part I. An event generator from the pion threshold up to 4 GeV