Photoproduction of pions on polarized protons and neutrons in the second resonance region