Index: /trunk/ppSkycell/src/ppSkycellLoop.c
===================================================================
--- /trunk/ppSkycell/src/ppSkycellLoop.c	(revision 24002)
+++ /trunk/ppSkycell/src/ppSkycellLoop.c	(revision 24003)
@@ -201,4 +201,12 @@
         psImageInit(image2, 0);
 
+        psImage *mask1 = NULL, *mask2 = NULL; // Binned masks
+        if (data->masksName) {
+            mask1 = psImageAlloc(numCols1, numRows1, PS_TYPE_IMAGE_MASK);
+            mask2 = psImageAlloc(numCols2, numRows2, PS_TYPE_IMAGE_MASK);
+            psImageInit(mask1, 0xFF);
+            psImageInit(mask2, 0xFF);
+        }
+
         for (int j = 0; j < data->numInputs; j++) {
             if (target->data.S32[j] != i) {
@@ -256,4 +264,8 @@
             psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "=");
             psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "=");
+            if (data->masksName) {
+                psImageOverlaySection(mask1, bin1RO->mask, xOffset1, yOffset1, "=");
+                psImageOverlaySection(mask2, bin2RO->mask, xOffset2, yOffset2, "=");
+            }
 
             psFree(bin1RO);
@@ -280,4 +292,6 @@
         ro1->image = image1;
         ro2->image = image2;
+        ro1->mask = mask1;
+        ro2->mask = mask2;
 
         ro1->data_exists = cell1->data_exists = cell1->parent->data_exists = true;
Index: /trunk/psModules/src/camera/pmFPABin.c
===================================================================
--- /trunk/psModules/src/camera/pmFPABin.c	(revision 24002)
+++ /trunk/psModules/src/camera/pmFPABin.c	(revision 24003)
@@ -28,10 +28,17 @@
     int numColsOut = binning->nXruff, numRowsOut = binning->nYruff; // Size of output image
 
-    // Output image
-    psImage *outImage;
+
+    psImage *outImage;                  // Output image
     if (out->image && out->image->numCols >= numColsOut && out->image->numRows >= numRowsOut) {
         outImage = out->image;
     } else {
         outImage = out->image = psImageRecycle(out->image,  numColsOut, numRowsOut, PS_TYPE_F32);
+    }
+
+    psImage *outMask;                   // Output mask
+    if (out->mask && out->mask->numCols >= numColsOut && out->mask->numRows >= numRowsOut) {
+        outMask = out->mask;
+    } else {
+        outMask = out->mask = psImageRecycle(out->mask,  numColsOut, numRowsOut, PS_TYPE_IMAGE_MASK);
     }
 
@@ -58,5 +65,14 @@
             }
 
-            outImage->data.F32[yOut][xOut] = numPix > 0 ? sum / numPix : NAN;
+            float imageValue, maskValue;// Values to set
+            if (numPix > 0) {
+                imageValue = sum / numPix;
+                maskValue = 0;
+            } else {
+                imageValue = NAN;
+                maskValue = maskVal;
+            }
+            outImage->data.F32[yOut][xOut] = imageValue;
+            outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue;
             xStart = xStop;
         }
