A dynamical model of pion photoproduction on the nucleon