constructMask function

Constructs a mask for a grid