BUG: check that the mask image matches dimension

Change-Id: I2fcb773de53dd71764e01bfffe05f8c87feda824