Index: /trunk/magic/remove/src/streaksio.c
===================================================================
--- /trunk/magic/remove/src/streaksio.c	(revision 27466)
+++ /trunk/magic/remove/src/streaksio.c	(revision 27467)
@@ -811,4 +811,5 @@
     }
     streaksVersionHeaderFull(sfile->header);
+
     if (!psFitsWriteImage(sfile->fits, sfile->header, sfile->image, 0, extname)) {
         psError(PS_ERR_IO, false, "failed to write image to %s extnum: %d",
@@ -871,4 +872,14 @@
 closeImages(streakFiles *sf)
 {
+    if (sf->stage == IPP_STAGE_RAW) {
+        if (sf->view) {
+            sf->view->readout = -1;
+            pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER);
+            sf->view->cell = -1;
+            pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER);
+            sf->view->chip = -1;
+            pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER);
+        }
+    }
     closeImage(sf->inImage);
     closeImage(sf->outImage);
@@ -1123,4 +1134,5 @@
 
         psImage *image = sfiles->outImage->image;
+        int imageType = image->type.type;
         double exciseValue = sfiles->inImage->exciseValue;
 
@@ -1143,5 +1155,16 @@
                 // these gets are not necessary, we could just set the pixels to nan
                 // but I want to get the counts
-                double imageVal  = image->data.F32[y][x];
+                double imageVal;
+                if (imageType == PS_TYPE_F32) {
+                    imageVal  = image->data.F32[y][x];
+                } else if (imageType == PS_TYPE_S16) {
+                    imageVal = image->data.S16[y][x];
+                } else if (imageType == PS_TYPE_U16) {
+                    imageVal = image->data.U16[y][x];
+                } else {
+                    psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
+                                imageType);
+                    streaksExit("", PS_EXIT_PROG_ERROR);
+                }
                 psU32 maskVal;
                 if (sfiles->stage == IPP_STAGE_RAW) {
@@ -1156,5 +1179,15 @@
                     if (!isExciseValue(imageVal, exciseValue)) {
                         ++nandPixels;
-                        image->data.F32[y][x] = exciseValue;
+                        if (imageType == PS_TYPE_F32) {
+                            image->data.F32[y][x] = exciseValue;
+                        } else if (imageType == PS_TYPE_S16) {
+                            image->data.S16[y][x] = exciseValue;
+                        } else if (imageType == PS_TYPE_U16) {
+                            image->data.U16[y][x] = exciseValue;
+                        } else {
+                            psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
+                                imageType);
+                            streaksExit("", PS_EXIT_PROG_ERROR);
+                        }
                     }
                     if (weight) {
