Added check for array in mask_img.