How can I create a mask by baking?
This simplest I have found is to assign separate material to them; one white emissive and one with black emissive, and then bake a texture with the Bake Type set to Emit.



You can also bake it from Diffuse if you already have black/white materials on them. You should then bake it from Color only.



Yet another way of doing this is to remove any backplanes, bake a Combined map (or any map BUT normal) and use the Alpha output of the baked texture as mask.



If you need to use the Compositing Editor to get the final image extracted from the image, you can use this setup: 


Open the Compositing Editor
Add an Image node and select your baked texture
Add a View node
Connect the Image Alpha to the Color of the View node.
Open the Image Editor and select the View Node as texture
Save the image from the Image Editor.