Generating object mask during rendering for data collection
If you are looking to create a black and white image of a portion of a mesh, make the portion you wish to capture a distinct material (top image). 

Assign the material a material pass (see yellow arrow), and collect and output that pass in your render (See render stack):



Here's a step-by-step, if this is your desired output: How to put 2 parts of 1 object on different layers?

Hand by SuperDasil on BlendSwap: https://www.blendswap.com/blends/view/81285