π0 Photo- and electroproduction at threshold within a dynamical model