diff --git a/BANE.py b/BANE.py
index <HASH>..<HASH> 100755
--- a/BANE.py
+++ b/BANE.py
@@ -344,6 +344,9 @@ def mask_img(data,mask_data):
     mask = np.where(np.isnan(mask_data))
     logging.debug(" mask, data = {0} {1}".format(len(mask),data.shape))
     logging.debug(" mask = {0}".format(mask))
+    if len(mask)>2:
+        mask = mask[-2], mask[-1]
+        logging.debug("mask = {0}".format(mask))
     try:
         data[mask]=np.NaN
     except IndexError:
files with NAXIS>2 no longer cause bane to crash