Magnetic fields and spiral arms in the galaxy M51