Initialize img and nodata_mask arrays together.