Index: /trunk/psModules/src/camera/pmFPAfileFitsIO.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 14203)
+++ /trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 14204)
@@ -26,6 +26,5 @@
     PS_ASSERT_PTR_NON_NULL(view, NULL);
 
-    if (//file->camera == config->camera || // Need to mosaic, not copy
-            !file->format) {                // Working with the same output format as input format
+    if (!file->format) {                // Working with the same output format as input format
         return psMemIncrRefCounter(file->fpa);
     }
@@ -82,7 +81,4 @@
     }
     psFree(phuView);
-
-    // preserve this state variable
-    copy->wrote_phu = file->fpa->wrote_phu;
 
     switch (level) {
@@ -467,2 +463,41 @@
 
 #endif
+
+bool pmFPAviewFitsWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
+
+    bool status = false;
+
+    if (file->mode != PM_FPA_MODE_WRITE) return true;
+    if (file->wrote_phu) return true;
+
+    // select or generate the desired fpa in the correct output format 
+    pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config);
+
+    switch (file->fileLevel) {
+      case PM_FPA_LEVEL_FPA:
+	status = pmFPAWrite(fpa, file->fits, NULL, true, false);
+	break;
+      case PM_FPA_LEVEL_CHIP: {
+	  pmChip *chip = pmFPAviewThisChip(view, fpa);
+	  status = pmChipWrite(chip, file->fits, NULL, true, false);
+	  break;
+      }
+      case PM_FPA_LEVEL_CELL: {
+	  pmCell *cell = pmFPAviewThisCell(view, fpa);
+	  status = pmCellWrite(cell, file->fits, NULL, true);
+	  break;
+      }
+      default:
+	psAbort("fileLevel not correctly set");
+	break;
+    }
+
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to write PHU for Image %s (%s)\n", file->filename, file->name);
+        return false;
+    }
+
+    psFree(fpa);
+    file->wrote_phu = true;
+    return true;
+}
