Add support for masked images, where the mask is written in the header and it is supplied via --mask_key