Index: trunk/pswarp/src/pswarpParseCamera.c
===================================================================
--- trunk/pswarp/src/pswarpParseCamera.c	(revision 12526)
+++ trunk/pswarp/src/pswarpParseCamera.c	(revision 12771)
@@ -11,6 +11,6 @@
     pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PSWARP.INPUT", "INPUT");
     if (!input) {
-	psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
-	return false;
+        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
+        return false;
     }
 
@@ -19,17 +19,19 @@
     pmFPAfileDefineFromArgs (&status, config, "PSWARP.ASTROM", "ASTROM");
     if (status) {
-	psLogMsg ("pswarp", 3, "using supplied astrometry\n");
+        psLogMsg ("pswarp", 3, "using supplied astrometry\n");
     } else {
-	psLogMsg ("pswarp", 3, "using header astrometry\n");
+        psLogMsg ("pswarp", 3, "using header astrometry\n");
     }
 
     // the mask is not required - but must conform to input camera
-    if (!pmFPAfileBindFromArgs (NULL, input, config, "PSWARP.MASK", "MASK")) {
-	psLogMsg ("pswarp", 3, "no mask supplied\n");
-    } 
+    pmFPAfile *inMask = pmFPAfileBindFromArgs(NULL, input, config, "PSWARP.MASK", "MASK");
+    if (!inMask) {
+        psLogMsg ("pswarp", 3, "no mask supplied\n");
+    }
 
-    if (!pmFPAfileBindFromArgs (NULL, input, config, "PSWARP.WEIGHT", "WEIGHT")) {
-	psLogMsg ("pswarp", 3, "no weight supplied\n");
-    } 
+    pmFPAfile *inWeight = pmFPAfileBindFromArgs(NULL, input, config, "PSWARP.WEIGHT", "WEIGHT");
+    if (!inWeight) {
+        psLogMsg ("pswarp", 3, "no weight supplied\n");
+    }
 
     // the input skycell is a required argument: it defines the output image
@@ -37,6 +39,6 @@
     status = pswarpDefineSkycell (&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL");
     if (!status) {
-	psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL");
-	return false;
+        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL");
+        return false;
     }
 
@@ -45,19 +47,31 @@
     // if (!pmFPAfileDefineFromFPA (skyConfig, skycell->fpa, 1, 1, "PSWARP.OUTPUT")) {
     if (!pmFPAfileDefineOutput (skyConfig, skycell->fpa, "PSWARP.OUTPUT")) {
-	psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT");
-	return false;
+        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT");
+        return false;
+    }
+    if (inMask) {
+        if (!pmFPAfileDefineOutput (skyConfig, skycell->fpa, "PSWARP.OUTPUT.MASK")) {
+            psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.MASK");
+            return false;
+        }
+    }
+    if (inWeight) {
+        if (!pmFPAfileDefineOutput (skyConfig, skycell->fpa, "PSWARP.OUTPUT.WEIGHT")) {
+            psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.WEIGHT");
+            return false;
+        }
     }
 
     // Chip selection: turn on only the chips specified
-    char *chipLine = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS"); 
+    char *chipLine = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
     psArray *chips = psStringSplitArray (chipLine, ",", false);
     if (chips->n > 0) {
-	pmFPASelectChip (input->fpa, -1, true); // deselect all chips
-	for (int i = 0; i < chips->n; i++) {
-	    int chipNum = atoi(chips->data[i]);
-	    if (! pmFPASelectChip(input->fpa, chipNum, false)) {
-		psError(PSWARP_ERR_CONFIG, true, "Chip number %d doesn't exist in camera.\n", chipNum);
-		return false;
-	    }
+        pmFPASelectChip (input->fpa, -1, true); // deselect all chips
+        for (int i = 0; i < chips->n; i++) {
+            int chipNum = atoi(chips->data[i]);
+            if (! pmFPASelectChip(input->fpa, chipNum, false)) {
+                psError(PSWARP_ERR_CONFIG, true, "Chip number %d doesn't exist in camera.\n", chipNum);
+                return false;
+            }
         }
     }
