How to use an object as a mask?
You can do this using the Object ID and a ID mask node.  

Select the object you want to use as a mask, and under the object tab in the properties set the Pass Index unequal 0 (I used 1, but if you have more then one mask give each one a different number)



Now, head over to the RenderLayers tab and check the Object ID pass



Re-render your image and head over to the node editor. There attach a ID Mask node to the IndexOB socket. Use the node's output as a factor for a mix node (See screenshot)



Here I used a test image, but you can use one from any source you want.