Index: src/sas/sascalc/dataloader/readers/associations.py
===================================================================
--- src/sas/sascalc/dataloader/readers/associations.py	(revision a32c19cb7f71822dacb02a8dd8c1e4967af341a7)
+++ src/sas/sascalc/dataloader/readers/associations.py	(revision c7c814358a478ddea9a6f8b57a46374c443b4776)
@@ -23,4 +23,5 @@
     ".ses": "sesans_reader",
     ".h5": "cansas_reader_HDF5",
+    ".nxs": "cansas_reader_HDF5",
     ".txt": "ascii_reader",
     ".dat": "red2d_reader",
Index: src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
===================================================================
--- src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py	(revision 9220e89c31ca5156d9c3a40634b4257084d139a2)
+++ src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py	(revision c7c814358a478ddea9a6f8b57a46374c443b4776)
@@ -567,11 +567,4 @@
         # Type cast data arrays to float64 and find min/max as appropriate
         for dataset in self.data2d:
-            zeros = np.ones(dataset.data.size, dtype=bool)
-            try:
-                for i in range(0, dataset.mask.size - 1):
-                    zeros[i] = dataset.mask[i]
-            except:
-                self.errors.append(sys.exc_value)
-            dataset.mask = zeros
             # Calculate the actual Q matrix
             try:
@@ -585,22 +578,15 @@
 
             if dataset.data.ndim == 2:
-                (n_rows, n_cols) = dataset.data.shape
-                flat_qy = dataset.qy_data[0::n_cols].flatten()
-                # For 2D arrays of Qx and Qy, the Q value should be constant
-                # along each row -OR- each column. The direction is not
-                # specified in the NXcanSAS standard.
-                if flat_qy[0] == flat_qy[1]:
-                    flat_qy = np.transpose(dataset.qy_data)[0::n_cols].flatten()
-                dataset.y_bins = np.unique(flat_qy)
-                flat_qx = dataset.qx_data[0::n_rows].flatten()
-                # For 2D arrays of Qx and Qy, the Q value should be constant
-                # along each row -OR- each column. The direction is not
-                # specified in the NXcanSAS standard.
-                if flat_qx[0] == flat_qx[1]:
-                    flat_qx = np.transpose(dataset.qx_data)[0::n_rows].flatten()
-                dataset.x_bins = np.unique(flat_qx)
+                dataset.y_bins = np.unique(dataset.qy_data.flatten())
+                dataset.x_bins = np.unique(dataset.qx_data.flatten())
                 dataset.data = dataset.data.flatten()
                 dataset.qx_data = dataset.qx_data.flatten()
                 dataset.qy_data = dataset.qy_data.flatten()
+
+            try:
+                iter(dataset.mask)
+                dataset.mask = np.invert(np.asarray(dataset.mask, dtype=bool))
+            except TypeError:
+                dataset.mask = np.ones(dataset.data.shape, dtype=bool)
             self.current_dataset = dataset
             self.send_to_output()
Index: src/sas/sascalc/file_converter/nxcansas_writer.py
===================================================================
--- src/sas/sascalc/file_converter/nxcansas_writer.py	(revision 9220e89c31ca5156d9c3a40634b4257084d139a2)
+++ src/sas/sascalc/file_converter/nxcansas_writer.py	(revision c7c814358a478ddea9a6f8b57a46374c443b4776)
@@ -328,5 +328,6 @@
         (n_rows, n_cols) = (len(data.y_bins), len(data.x_bins))
 
-        if n_rows == 0 and n_cols == 0:
+        if ((n_rows == 0 and n_cols == 0)
+                or (n_cols*n_rows != len(data.data.flatten()))):
             # Calculate rows and columns, assuming detector is square
             # Same logic as used in PlotPanel.py _get_bins
@@ -360,2 +361,6 @@
             dqy_entry = data_entry.create_dataset('dQy', data=data.dqy_data)
             dqy_entry.attrs['units'] = data.Q_unit
+        if data.mask is not None and not all(data.mask == [None]):
+            data_entry.attrs['mask'] = "mask"
+            mask = np.invert(np.asarray(data.mask, dtype=bool))
+            data_entry.create_dataset('mask', data=mask)
