Using the boat as a drive holder is a great idea. Before getting your boat out, you might be able to remove them using the following procedure:
Once you've loosened or removed the Allenhead screw, you should be able to set the drive down on a table and, using a padded
set of vice grips or pliers, gently twist the old mast as you extract it with one hand while stabilizing the drive with the other. It's all in the twist!
When installing the new masts, make sure they're fully seated and properly aligned. Snug, but don't over tighten the Allenheads and don't over tighten the clew screws (if that's the style you have). The rear sprocket protector should be able to pivot on its shaft.