Index: trunk/stac/src/stac.c
===================================================================
--- trunk/stac/src/stac.c	(revision 2897)
+++ trunk/stac/src/stac.c	(revision 3375)
@@ -77,7 +77,12 @@
 
 #ifdef TESTING
-    char prefile[MAXCHAR];		// Filename of precombined image
-    sprintf(prefile,"%s.pre",config->output);
-    psImageWriteSection(combined,0,0,0,NULL,0,prefile);
+    char preName[MAXCHAR];		// Filename of precombined image
+    sprintf(preName,"%s.pre",config->output);
+    psFits *preFile = psFitsAlloc(preName);
+    if (!psFitsWriteImage(preFile, NULL, combined, 0, NULL)) {
+	psErrorStackPrint(stderr, "Unable to write image: %s\n", preName);
+    }
+    psTrace("stac", 1, "Pre-combined image written to %s\n", preName);
+    psFree(preFile);
 #endif
 
@@ -89,7 +94,12 @@
 					      ((psImage*)(inputs->data[i]))->numRows);
 #ifdef TESTING
-	char regionFile[MAXCHAR];	// Filename of region image
-	sprintf(regionFile,"%s.region",config->inputs->data[i]);
-	psImageWriteSection(regions->data[i], 0, 0, 0, NULL, 0, regionFile);
+	char regionName[MAXCHAR];	// Filename of region image
+	sprintf(regionName,"%s.region",config->inputs->data[i]);
+	psFits *regionFile = psFitsAlloc(regionName);
+	if (!psFitsWriteImage(regionFile, NULL, regions->data[i], 0, NULL)) {
+	    psErrorStackPrint(stderr, "Unable to write image: %s\n", regionName);
+	}
+	psTrace("stac", 1, "Region image written to %s\n", regionName);
+	psFree(regionFile);
 #endif
     }
@@ -122,5 +132,10 @@
 
     // Write output image
-    psImageWriteSection(combined,0,0,0,NULL,0,config->output);
+    psFits *outFile = psFitsAlloc(config->output);
+    if (!psFitsWriteImage(outFile, NULL, combined, 0, NULL)) {
+	psErrorStackPrint(stderr, "Unable to write image: %s\n", config->output);
+    }
+    psTrace("stac", 1, "Combined image written to %s\n", config->output);
+    psFree(outFile);
 
     // Free everything I've used
