Index: /branches/eam_branch_20081230/ppArith/src/ppArithReadout.c
===================================================================
--- /branches/eam_branch_20081230/ppArith/src/ppArithReadout.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppArith/src/ppArithReadout.c	(revision 21087)
@@ -26,5 +26,5 @@
         outImage = output->mask;
         if (!outImage) {
-            output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_MASK);
+            output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_IMAGE_MASK);
         }
         if (!output->image) {
@@ -37,5 +37,5 @@
         outImage = output->image;
         if (!outImage) {
-            output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_MASK);
+            output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_IMAGE_MASK);
         }
     }
Index: /branches/eam_branch_20081230/ppImage/src/ppImage.h
===================================================================
--- /branches/eam_branch_20081230/ppImage/src/ppImage.h	(revision 21086)
+++ /branches/eam_branch_20081230/ppImage/src/ppImage.h	(revision 21087)
@@ -58,10 +58,10 @@
 
     // make values for abstract concepts of masking
-    psMaskType maskValue;               // apply this bit-mask to choose masked bits
-    psMaskType markValue;               // apply this bit-mask to choose masked bits
-    psMaskType satMask;                 // Mask value to give saturated pixels
-    psMaskType badMask;                 // Mask value to give bad pixels
-    psMaskType flatMask;                // Mask value to give bad flat pixels
-    psMaskType blankMask;               // Mask value to give blank pixels
+    psImageMaskType maskValue;               // apply this bit-mask to choose masked bits
+    psImageMaskType markValue;               // apply this bit-mask to choose masked bits
+    psImageMaskType satMask;                 // Mask value to give saturated pixels
+    psImageMaskType badMask;                 // Mask value to give bad pixels
+    psImageMaskType flatMask;                // Mask value to give bad flat pixels
+    psImageMaskType blankMask;               // Mask value to give blank pixels
 
     // non-linear correction parameters
Index: /branches/eam_branch_20081230/ppImage/src/ppImageReplaceBackground.c
===================================================================
--- /branches/eam_branch_20081230/ppImage/src/ppImageReplaceBackground.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppImage/src/ppImageReplaceBackground.c	(revision 21087)
@@ -30,8 +30,8 @@
     // XXX Should this be options->maskValue or options->maskValue & ~options->satMask?
     //     The latter will leave saturated pixels high
-    psMaskType maskVal = options->maskValue;
+    psImageMaskType maskVal = options->maskValue;
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
+    psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
 
     // Since we are working on a chip-mosaicked image, there should only be a single cell and readout
@@ -146,5 +146,5 @@
             if (!isfinite(value)) {
                 image->data.F32[y][x] = NAN;
-                mask->data.PS_TYPE_MASK_DATA[y][x] |= options->badMask;
+                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->badMask;
             } else {
                 image->data.F32[y][x] -= value;
@@ -157,5 +157,5 @@
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+            if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                 image->data.F32[y][x] = 0.0;
             } else {
@@ -163,5 +163,5 @@
                 if (!isfinite(value)) {
                     image->data.F32[y][x] = NAN;
-                    mask->data.PS_TYPE_MASK_DATA[y][x] |= options->badMask;
+                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->badMask;
                 } else {
                     image->data.F32[y][x] -= value;
Index: /branches/eam_branch_20081230/ppImage/src/ppImageSetMaskBits.c
===================================================================
--- /branches/eam_branch_20081230/ppImage/src/ppImageSetMaskBits.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppImage/src/ppImageSetMaskBits.c	(revision 21087)
@@ -38,6 +38,6 @@
 
     // set maskValue and markValue in the psphot recipe
-    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);
-    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);
+    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);
+    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);
 
     return true;
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeArguments.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeArguments.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeArguments.c	(revision 21087)
@@ -94,6 +94,6 @@
         } \
     } \
-    psMaskType mask = pmConfigMask(str, config); \
-    psMetadataAddU8(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, mask); \
+    psImageMaskType mask = pmConfigMask(str, config); \
+    psMetadataAddImageMask(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, mask); \
 }
 
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeLoop.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeLoop.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeLoop.c	(revision 21087)
@@ -38,6 +38,6 @@
 
     // set the mask and mark bit values based on the named masks
-    psMaskType maskVal;
-    psMaskType markVal;
+    psImageMaskType maskVal;
+    psImageMaskType markVal;
     if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) {
 	psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeLoop_Threaded.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeLoop_Threaded.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeLoop_Threaded.c	(revision 21087)
@@ -54,6 +54,6 @@
 
     // set the mask and mark bit values based on the named masks
-    psMaskType maskVal;
-    psMaskType markVal;
+    psImageMaskType maskVal;
+    psImageMaskType markVal;
     if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) {
         psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
@@ -257,5 +257,5 @@
                       psArrayAdd(job->args, 1, psScalarAlloc(iter, PS_TYPE_S32));
                       psArrayAdd(job->args, 1, psScalarAlloc(rej, PS_TYPE_F32));
-                      psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_U8));
+                      psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_IMAGE_MASK));
 
                       // call: pmDarkCombine(outCell, fileGroup->readouts, iter, rej, maskVal);
@@ -276,5 +276,5 @@
                       psArrayAdd(job->args, 1, psScalarAlloc(iter, PS_TYPE_S32));
                       psArrayAdd(job->args, 1, psScalarAlloc(rej, PS_TYPE_F32));
-                      psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_U8));
+                      psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_IMAGE_MASK));
 
                       // call: pmShutterCorrectionGenerate(outRO, pattern, fileGroup->readouts, shutterRef,
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeMask.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeMask.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeMask.c	(revision 21087)
@@ -26,6 +26,6 @@
     float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask
 
-    psMaskType markVal;
-    psMaskType maskValRaw;
+    psImageMaskType markVal;
+    psImageMaskType maskValRaw;
     if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) {
 	psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
@@ -34,5 +34,5 @@
 
     char *maskOutName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE");
-    psMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
+    psImageMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
     if (!maskValOut) {
 	psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
@@ -137,6 +137,6 @@
                 int x = pixel % numCols;
                 int y = pixel / numCols;
-                if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValRaw)) continue;
-		if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue;
+                if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue;
+		if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
 		if (!isfinite(image->data.F32[y][x])) continue;
 
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeScaleZero.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeScaleZero.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeScaleZero.c	(revision 21087)
@@ -80,5 +80,5 @@
                 pmReadout *readout = cell->readouts->data[0]; // Readout of interest
 
-                psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
+                psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
 
                 switch (type) {
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeSetThreads.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeSetThreads.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeSetThreads.c	(revision 21087)
@@ -29,5 +29,5 @@
     psScalar *maskVal           = job->args->data[4];
 
-    bool status = pmDarkCombine(outCell, fileGroup->readouts, iter->data.S32, rej->data.F32, maskVal->data.U8);
+    bool status = pmDarkCombine(outCell, fileGroup->readouts, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
 
     // after we are done, tell the I/O system that this file group is done
@@ -49,5 +49,5 @@
     psScalar *maskVal             = job->args->data[7];
 
-    bool status = pmShutterCorrectionGenerate(output, pattern, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.U8);
+    bool status = pmShutterCorrectionGenerate(output, pattern, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
 
     // after we are done, tell the I/O system that this file group is done
Index: /branches/eam_branch_20081230/ppMerge/src/ppMergeThreadLauncher.c
===================================================================
--- /branches/eam_branch_20081230/ppMerge/src/ppMergeThreadLauncher.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppMerge/src/ppMergeThreadLauncher.c	(revision 21087)
@@ -60,5 +60,5 @@
 	    psScalar *maskVal     	= job->args->data[6];
 
-	    bool status = pmDarkCombine(outCell, fileGroup->readouts, darkOrdinates, darkNorm, iter->data.S32, rej->data.F32, maskVal->data.U8);
+	    bool status = pmDarkCombine(outCell, fileGroup->readouts, darkOrdinates, darkNorm, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
 	    if (!status) {
 		self->fault = true;
@@ -82,5 +82,5 @@
 	    psScalar *maskVal     	  = job->args->data[6];
 
-	    bool status = pmShutterCorrectionGenerate(output, NULL, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.U8);
+	    bool status = pmShutterCorrectionGenerate(output, NULL, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
 	    if (!status) {
 		self->fault = true;
Index: /branches/eam_branch_20081230/ppSim/src/ppSimMosaicChip.c
===================================================================
--- /branches/eam_branch_20081230/ppSim/src/ppSimMosaicChip.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppSim/src/ppSimMosaicChip.c	(revision 21087)
@@ -2,5 +2,5 @@
 
 // XXX this is essentially identical to ppImageMosaicChip
-bool ppSimMosaicChip(pmConfig *config, const psMaskType blankMask, const pmFPAview *view,
+bool ppSimMosaicChip(pmConfig *config, const psImageMaskType blankMask, const pmFPAview *view,
                        const char *outFile, const char *inFile)
 {
Index: /branches/eam_branch_20081230/ppSim/src/ppSimPhotom.c
===================================================================
--- /branches/eam_branch_20081230/ppSim/src/ppSimPhotom.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppSim/src/ppSimPhotom.c	(revision 21087)
@@ -15,4 +15,5 @@
     psphotInit ();
 
+ XXX : should this be a psImageMaskType?
     int blankMask = 0;		// XXX not sure what this should be set to...
     ppSimMosaicChip(config, blankMask, view, "PPSIM.FORCE.CHIP", "PPSIM.INPUT");
Index: /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadout.c
===================================================================
--- /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadout.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadout.c	(revision 21087)
@@ -96,5 +96,5 @@
 
     // XXX fake sources should measure peak->x,y, force sources should not
-    psMaskType maskVal = 0xff; 
+    psImageMaskType maskVal = 0xff; 
     psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
     ppSimDetections (significance, recipe, fakeSources);
Index: /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadoutFake.c
===================================================================
--- /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadoutFake.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadoutFake.c	(revision 21087)
@@ -76,5 +76,5 @@
 
     // XXX fake sources should measure peak->x,y, force sources should not
-    psMaskType maskVal = 0xff; 
+    psImageMaskType maskVal = 0xff; 
     psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
     ppSimDetections (significance, recipe, fakeSources);
Index: /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadoutForce.c
===================================================================
--- /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadoutForce.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppSim/src/ppSimPhotomReadoutForce.c	(revision 21087)
@@ -69,5 +69,5 @@
 
     // XXX fake sources should measure peak->x,y, force sources should not
-    psMaskType maskVal = 0xff; 
+    psImageMaskType maskVal = 0xff; 
     psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
     ppSimDetections (significance, recipe, forceSources);
Index: /branches/eam_branch_20081230/ppStats/src/ppStats.h
===================================================================
--- /branches/eam_branch_20081230/ppStats/src/ppStats.h	(revision 21086)
+++ /branches/eam_branch_20081230/ppStats/src/ppStats.h	(revision 21087)
@@ -24,5 +24,5 @@
     bool doFirstReadout3D;		// for 3D data, use the first readout?
     float sample;                       // Fraction of cell to sample for statistics
-    psMaskType maskVal;                 // Mask value for images
+    psImageMaskType maskVal;		// Mask value for images
     psList *chips;                      // Chips to look at
     psList *cells;                      // Cells to look at
@@ -45,5 +45,5 @@
                        pmFPA *fpa,         // FPA for which to get statistics
                        pmFPAview *view,    // View for analysis
-                       psMaskType maskVal, // Value to mask
+                       psImageMaskType maskVal, // Value to mask
                        pmConfig *config    // Configuration
     );
@@ -77,5 +77,5 @@
                           pmFPA *fpa,         // FPA for which to get statistics
                           pmFPAview *view,    // View for analysis
-                          psMaskType maskVal, // Value to mask
+                          psImageMaskType maskVal, // Value to mask
                           pmConfig *config    // Configuration
     );
@@ -85,5 +85,5 @@
                             pmFPA *fpa,         // FPA for which to get statistics
                             pmFPAview *view,    // View for analysis
-                            psMaskType maskVal, // Value to mask
+                            psImageMaskType maskVal, // Value to mask
                             pmConfig *config    // Configuration
     );
Index: /branches/eam_branch_20081230/ppStats/src/ppStatsFPA.c
===================================================================
--- /branches/eam_branch_20081230/ppStats/src/ppStatsFPA.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppStats/src/ppStatsFPA.c	(revision 21087)
@@ -4,5 +4,5 @@
 		       pmFPA *fpa,         // FPA for which to get statistics
 		       pmFPAview *view,    // View for analysis
-		       psMaskType maskVal, // Value to mask
+		       psImageMaskType maskVal, // Value to mask
 		       pmConfig *config    // Configuration
     )
Index: /branches/eam_branch_20081230/ppStats/src/ppStatsMetadata.c
===================================================================
--- /branches/eam_branch_20081230/ppStats/src/ppStatsMetadata.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppStats/src/ppStatsMetadata.c	(revision 21087)
@@ -5,5 +5,5 @@
 			    pmFPA *fpa,         // FPA for which to get statistics
 			    pmFPAview *view,    // View for analysis
-			    psMaskType maskVal, // Value to mask
+			    psImageMaskType maskVal, // Value to mask
 			    pmConfig *config    // Configuration
     )
Index: /branches/eam_branch_20081230/ppStats/src/ppStatsPixels.c
===================================================================
--- /branches/eam_branch_20081230/ppStats/src/ppStatsPixels.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppStats/src/ppStatsPixels.c	(revision 21087)
@@ -5,5 +5,5 @@
 			  pmFPA *fpa,         // FPA for which to get statistics
 			  pmFPAview *view,    // View for analysis
-			  psMaskType maskVal, // Value to mask
+			  psImageMaskType maskVal, // Value to mask
 			  pmConfig *config    // Configuration
     )
Index: /branches/eam_branch_20081230/ppStats/src/ppStatsReadout.c
===================================================================
--- /branches/eam_branch_20081230/ppStats/src/ppStatsReadout.c	(revision 21086)
+++ /branches/eam_branch_20081230/ppStats/src/ppStatsReadout.c	(revision 21087)
@@ -63,5 +63,5 @@
         int sampleSpace = 1.0 / data->sample; // Space between samples
         psVector *sampleValues = psVectorAlloc(numSamples, PS_TYPE_F32); // Vector of samples
-        psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_MASK);  // Corresponding mask
+        psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_VECTOR_MASK);  // Corresponding mask
         if (!mask) {
             psVectorInit(sampleMask, 0);
@@ -72,17 +72,15 @@
             int x = j % image->numCols;
             sampleValues->data.F32[i] = image->data.F32[y][x];
-            if ((!mask || !(mask->data.PS_TYPE_MASK_DATA[y][x] & data->maskVal)) &&
-                !isfinite(sampleValues->data.F32[i])) {
+            if ((!mask || !(mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & data->maskVal)) && !isfinite(sampleValues->data.F32[i])) {
                 if (!warnNonFinite) {
-                    psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings",
-                              x, y);
+                    psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings", x, y);
                     warnNonFinite = true;
                 }
-                sampleMask->data.PS_TYPE_MASK_DATA[i] = data->maskVal;
+                sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
             } else if (mask) {
-                sampleMask->data.PS_TYPE_MASK_DATA[i] = mask->data.PS_TYPE_MASK_DATA[y][x];
+	      sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
             }
         }
-        if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, data->maskVal)) {
+        if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, 1)) {
             psWarning("Unable to perform statistics on readout %s.\n", readoutName);
             psErrorClear();
@@ -179,5 +177,5 @@
                 for (int j = 0; j < readout->mask->numRows; j++) {
                     for (int i = 0; i < readout->mask->numCols; i++) {
-                        if (readout->mask->data.PS_TYPE_MASK_DATA[j][i] & data->maskVal) {
+                        if (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & data->maskVal) {
                             numBad++;
                         }
Index: /branches/eam_branch_20081230/psastro/src/psastroAstromGuess.c
===================================================================
--- /branches/eam_branch_20081230/psastro/src/psastroAstromGuess.c	(revision 21086)
+++ /branches/eam_branch_20081230/psastro/src/psastroAstromGuess.c	(revision 21087)
@@ -267,5 +267,5 @@
     psVector *cornerDn = psVectorAllocEmpty (100, PS_TYPE_F32);
 
-    psVector *cornerMK = psVectorAllocEmpty (100, PS_TYPE_U8);
+    psVector *cornerMK = psVectorAllocEmpty (100, PS_TYPE_VECTOR_MASK);
 
     if (DEBUG) psastroDumpCorners ("corners.up.guess3.dat", "corners.dn.guess3.dat", fpa);
Index: /branches/eam_branch_20081230/psastro/src/psastroFixChips.c
===================================================================
--- /branches/eam_branch_20081230/psastro/src/psastroFixChips.c	(revision 21086)
+++ /branches/eam_branch_20081230/psastro/src/psastroFixChips.c	(revision 21087)
@@ -160,5 +160,5 @@
     psPlaneTransform *map = psPlaneTransformAlloc (1, 1);
   
-    psVector *mask = psVectorAlloc (nPts, PS_TYPE_U8);
+    psVector *mask = psVectorAlloc (nPts, PS_TYPE_VECTOR_MASK);
     psVectorInit (mask, 0);
 
Index: /branches/eam_branch_20081230/psastro/src/psastroLuminosityFunction.c
===================================================================
--- /branches/eam_branch_20081230/psastro/src/psastroLuminosityFunction.c	(revision 21086)
+++ /branches/eam_branch_20081230/psastro/src/psastroLuminosityFunction.c	(revision 21087)
@@ -91,5 +91,5 @@
     psLogMsg ("psastro", 4, "fitting %d points to luminosity function\n", n);
 
-    psVector *mask = psVectorAlloc (Mag->n, PS_TYPE_MASK);
+    psVector *mask = psVectorAlloc (Mag->n, PS_TYPE_VECTOR_MASK);
     psVectorInit (mask, 0);
 
@@ -108,5 +108,5 @@
     double mMaxValid = NAN;
     for (int i = 0; i < Mag->n; i++) {
-        if (mask->data.U8[i]) continue;
+        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
         if (isnan(mMinValid) || (Mag->data.F32[i] < mMinValid)) {
             mMinValid = Mag->data.F32[i];
Index: /branches/eam_branch_20081230/psastro/src/psastroMaskUpdates.Mosaic.c
===================================================================
--- /branches/eam_branch_20081230/psastro/src/psastroMaskUpdates.Mosaic.c	(revision 21086)
+++ /branches/eam_branch_20081230/psastro/src/psastroMaskUpdates.Mosaic.c	(revision 21087)
@@ -9,9 +9,9 @@
 pmCell *pmCellInChip (pmChip *chip, float x, float y);
 bool pmCellCoordsForChip (float *xCell, float *yCell, pmCell *cell, float xChip, float yChip);
-bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY);
-bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta);
-void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW);
-void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
-void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1);
+bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY);
+bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta);
+void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW);
+void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
+void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1);
 
 // create a mask or mask regions based on the collection of reference stars that are 
@@ -25,6 +25,6 @@
     float zeropt, exptime;
 
-    psMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
-    psMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
+    psImageMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
+    psImageMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
 
     // select the current recipe
@@ -342,5 +342,5 @@
 
 // XXX should be doing an OR
-bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY) {
+bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY) {
 
     // XXX need to worry about row0, col0
@@ -357,5 +357,5 @@
 	    if (r2 > 1.0) continue;
 	    
-	    mask->data.U8[jy][jx] |= value;
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[jy][jx] |= value;
 	}
     }
@@ -364,5 +364,5 @@
 
 // XXX should be doing an OR
-bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta) {
+bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta) {
 
     // draw a series of lines (from -0.5*dW to +0.5*dW) of length dL, starting at x0, y0, angle theta
@@ -379,5 +379,5 @@
 
 // identify the quadrant and draw the correct line
-void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW) {
+void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW) {
 
   int FlipDirect, FlipCoords;
@@ -408,5 +408,5 @@
 // use the Bresenham line drawing technique
 // integer-only Bresenham line-draw version which is fast
-void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
+void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
 
     int X, Y, dX, dY;
@@ -425,5 +425,5 @@
 		    if (y < 0) continue;
 		    if (y >= mask->numCols) continue;
-		    mask->data.U8[X][y] |= value;
+		    mask->data.PS_TYPE_IMAGE_MASK_DATA[X][y] |= value;
 		}
 	    } else {
@@ -432,5 +432,5 @@
 		    if (y < 0) continue;
 		    if (y >= mask->numRows) continue;
-		    mask->data.U8[y][X] |= value;
+		    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][X] |= value;
 		}
 	    }
@@ -450,10 +450,10 @@
 }
 
-void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1) {
+void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1) {
     for (int iy = PS_MAX(0,y0); iy < PS_MIN(y1,mask->numRows); iy++) {
 	for (int ix = PS_MAX(0,x0); ix < PS_MIN(x1,mask->numCols); ix++) {
-	    mask->data.U8[iy][ix] |= value;
-	}
-    }
-}
-
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= value;
+	}
+    }
+}
+
Index: /branches/eam_branch_20081230/psastro/src/psastroMaskUpdates.c
===================================================================
--- /branches/eam_branch_20081230/psastro/src/psastroMaskUpdates.c	(revision 21086)
+++ /branches/eam_branch_20081230/psastro/src/psastroMaskUpdates.c	(revision 21087)
@@ -11,9 +11,9 @@
 bool pmChipCoordsForCell (float *xChip, float *yChip, pmCell *cell, float xCell, float yCell);
 
-bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY);
-bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta);
-void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW);
-void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
-void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1);
+bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY);
+bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta);
+void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW);
+void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
+void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1);
 
 // create a mask or mask regions based on the collection of reference stars that are
@@ -27,7 +27,7 @@
     float zeropt, exptime;
 
-    psMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
-
-    // psMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
+    psImageMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
+
+    // psImageMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
 
     // select the current recipe
@@ -376,5 +376,5 @@
 
 // XXX should be doing an OR
-bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY) {
+bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY) {
 
     // XXX need to worry about row0, col0
@@ -391,5 +391,5 @@
             if (r2 > 1.0) continue;
 
-            mask->data.U8[jy][jx] |= value;
+            mask->data.PS_TYPE_IMAGE_MASK_DATA[jy][jx] |= value;
         }
     }
@@ -398,5 +398,5 @@
 
 // XXX should be doing an OR
-bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta) {
+bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta) {
 
     // draw a series of lines (from -0.5*dW to +0.5*dW) of length dL, starting at x0, y0, angle theta
@@ -413,5 +413,5 @@
 
 // identify the quadrant and draw the correct line
-void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW) {
+void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW) {
 
   int FlipDirect, FlipCoords;
@@ -442,5 +442,5 @@
 // use the Bresenham line drawing technique
 // integer-only Bresenham line-draw version which is fast
-void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
+void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
 
     int X, Y, dX, dY;
@@ -459,5 +459,5 @@
                     if (y < 0) continue;
                     if (y >= mask->numCols) continue;
-                    mask->data.U8[X][y] |= value;
+                    mask->data.PS_TYPE_IMAGE_MASK_DATA[X][y] |= value;
                 }
             } else {
@@ -466,5 +466,5 @@
                     if (y < 0) continue;
                     if (y >= mask->numRows) continue;
-                    mask->data.U8[y][X] |= value;
+                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][X] |= value;
                 }
             }
@@ -484,5 +484,5 @@
 }
 
-void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1) {
+void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1) {
 
     int xs = PS_MAX (0, PS_MIN (mask->numCols, PS_MIN (x0, x1)));
@@ -493,7 +493,7 @@
     for (int iy = ys; iy < ye; iy++) {
         for (int ix = xs; ix < xe; ix++) {
-            mask->data.U8[iy][ix] |= value;
-        }
-    }
-}
-
+            mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= value;
+        }
+    }
+}
+
Index: /branches/eam_branch_20081230/psastro/src/psastroMosaicFPtoTP.c
===================================================================
--- /branches/eam_branch_20081230/psastro/src/psastroMosaicFPtoTP.c	(revision 21086)
+++ /branches/eam_branch_20081230/psastro/src/psastroMosaicFPtoTP.c	(revision 21087)
@@ -74,5 +74,5 @@
 
     // constant errors
-    psVector *mask = psVectorAlloc (X->n, PS_TYPE_U8);
+    psVector *mask = psVectorAlloc (X->n, PS_TYPE_VECTOR_MASK);
     psVectorInit (mask, 0);
 
Index: /branches/eam_branch_20081230/psphot/src/psphot.h
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphot.h	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphot.h	(revision 21087)
@@ -18,6 +18,6 @@
     pmPSF *psf;
     psRegion *region;
-    psMaskType maskVal;
-    psMaskType markVal;
+    psImageMaskType maskVal;
+    psImageMaskType markVal;
 } psphotGuessModelForRegionArgs;
 
@@ -53,5 +53,5 @@
 bool            psphotGuessModelForRegion (psphotGuessModelForRegionArgs *args);
 bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
-bool            psphotReplaceUnfitSources (psArray *sources, psMaskType maskVal);
+bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
 bool            psphotReplaceAllSources (psArray *sources, psMetadata *recipe);
 bool            psphotRemoveAllSources (psArray *sources, psMetadata *recipe);
@@ -64,7 +64,7 @@
 
 // used by psphotFindDetections
-psImage        *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal);
+psImage        *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal);
 psArray        *psphotFindPeaks (psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int nMax);
-bool            psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal);
+bool            psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal);
 psErrorCode     psphotCullPeaks(const psImage *img, const psImage *weight, const psMetadata *recipe, psArray *footprints);
 
@@ -75,5 +75,5 @@
 // basic support functions
 void            psphotModelClassInit (void);
-bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal);
+bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal);
 bool            psphotSetMaskAndWeight (pmConfig *config, pmReadout *readout, psMetadata *recipe);
 void            psphotSourceFreePixels (psArray *sources);
@@ -81,8 +81,8 @@
 // functions to set the correct source pixels
 bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
-bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
-bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR);
+bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal);
+bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal, float dR);
 bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
-bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
+bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal);
 
 // output functions
@@ -103,12 +103,12 @@
 bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
 bool            psphotInitLimitsEXT (psMetadata *recipe);
-bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
-bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
-bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
-pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal);
-psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal);
+bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);
+bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);
+bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);
+pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal);
+psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal);
 
 // functions to support simultaneous multi-source fitting
-bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psMaskType maskVal);
+bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psImageMaskType maskVal);
 
 // plotting functions (available if libkapa is installed)
@@ -131,21 +131,21 @@
 bool            psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize);
 
-bool            psphotAddWithTest (pmSource *source, bool useState, psMaskType maskVal);
-bool            psphotSubWithTest (pmSource *source, bool useState, psMaskType maskVal);
-bool            psphotSetState (pmSource *source, bool curState, psMaskType maskVal);
+bool            psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal);
+bool            psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal);
+bool            psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal);
 bool            psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
 bool            psphotSourceSize (pmConfig *config, pmReadout *readout, psArray *sources, psMetadata *recipe, long first);
 
-bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal);
-
-pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize);
+bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal);
+
+pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize);
 
 psKernel       *psphotKernelFromPSF (pmSource *source, int nPix);
 
-bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal);
-bool            psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal);
-bool            psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal);
-bool            psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal);
-bool            psphotKron (pmSource *source, psMetadata *recipe, psMaskType maskVal);
+bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
+bool            psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
+bool            psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
+bool            psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
+bool            psphotKron (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
 
 // psphotVisual functions
@@ -162,5 +162,5 @@
 bool psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf);
-bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psMaskType maskVal);
+bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal);
 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources);
 bool psphotVisualShowFlags (psArray *sources);
@@ -217,5 +217,5 @@
 bool psphotMakeFluxScale (psImage *image, psMetadata *recipe, pmPSF *psf);
 bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
-bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psMaskType maskVal, psMaskType markVal);
+bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal);
 
 bool psphotCheckStarDistribution (psArray *sources, psArray *stars, pmPSFOptions *options);
Index: /branches/eam_branch_20081230/psphot/src/psphotAddNoise.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotAddNoise.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotAddNoise.c	(revision 21087)
@@ -23,5 +23,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotAnnuli.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotAnnuli.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotAnnuli.c	(revision 21087)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
+bool psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
 
   assert (source->extpars);
Index: /branches/eam_branch_20081230/psphot/src/psphotApResid.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotApResid.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotApResid.c	(revision 21087)
@@ -33,9 +33,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
@@ -70,5 +70,5 @@
     pmSourceMagnitudesInit (recipe);
 
-    psVector *mask    = psVectorAllocEmpty (300, PS_TYPE_U8);
+    psVector *mask    = psVectorAllocEmpty (300, PS_TYPE_VECTOR_MASK);
     psVector *mag     = psVectorAllocEmpty (300, PS_TYPE_F32);
     psVector *xPos    = psVectorAllocEmpty (300, PS_TYPE_F32);
@@ -118,5 +118,5 @@
         yPos->data.F32[Npsf]    = model->params->data.F32[PM_PAR_YPOS];
 
-        mask->data.U8[Npsf] = 0;
+        mask->data.PS_TYPE_VECTOR_MASK_DATA[Npsf] = 0;
 
         dMag->data.F32[Npsf] = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
@@ -197,5 +197,5 @@
                      mag->data.F32[i], dMag->data.F32[i], dMagSys->data.F32[i],
                      apResid->data.F32[i], apResidRes->data.F32[i],
-                     mask->data.U8[i]);
+                     mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
         }
         fclose (dumpFile);
@@ -263,5 +263,5 @@
     psVector *dMSubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
     psVector *dASubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
-    psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_U8);
+    psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK);
 
     int n = 0;
@@ -272,5 +272,5 @@
             dMSubset->data.F32[j] = dMag->data.F32[N];
             dASubset->data.F32[j] = dap->data.F32[N];
-            mkSubset->data.U8[j]  = mask->data.U8[N];
+            mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j] = mask->data.PS_TYPE_VECTOR_MASK_DATA[N];
         }
         dMSubset->n = j;
Index: /branches/eam_branch_20081230/psphot/src/psphotBlendFit.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotBlendFit.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotBlendFit.c	(revision 21087)
@@ -13,9 +13,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotChoosePSF.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotChoosePSF.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotChoosePSF.c	(revision 21087)
@@ -24,9 +24,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
@@ -258,5 +258,5 @@
     for (int i = 0; i < try->sources->n; i++) {
         pmSource *source = try->sources->data[i];
-        if (try->mask->data.U8[i]) {
+        if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
         }
Index: /branches/eam_branch_20081230/psphot/src/psphotExtendedSourceAnalysis.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotExtendedSourceAnalysis.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotExtendedSourceAnalysis.c	(revision 21087)
@@ -12,5 +12,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotExtendedSourceFits.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotExtendedSourceFits.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotExtendedSourceFits.c	(revision 21087)
@@ -13,8 +13,8 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     assert (markVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotExtendedSources.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotExtendedSources.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotExtendedSources.c	(revision 21087)
@@ -12,5 +12,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotFindDetections.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotFindDetections.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotFindDetections.c	(revision 21087)
@@ -10,5 +10,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotFindFootprints.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotFindFootprints.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotFindFootprints.c	(revision 21087)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal) {
+bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal) {
 
     bool status;
Index: /branches/eam_branch_20081230/psphot/src/psphotFitSet.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotFitSet.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotFitSet.c	(revision 21087)
@@ -2,5 +2,5 @@
 
 // This is only used by psphotModelTest.c
-bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psMaskType maskVal) {
+bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psImageMaskType maskVal) {
 
     double x, y, Io;
Index: /branches/eam_branch_20081230/psphot/src/psphotFitSourcesLinear.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotFitSourcesLinear.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotFitSourcesLinear.c	(revision 21087)
@@ -10,5 +10,5 @@
 // the analysis is performed wrt the simulated pixel values
 
-static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal);
+static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal);
 
 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
@@ -23,9 +23,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
@@ -233,5 +233,5 @@
 // on the pixels which correspond to all of the sources of interest.  These elements fill in
 // the border matrix components in the sparse matrix equation.
-static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal) {
+static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal) {
 
     // generate the image-wide weight terms
@@ -248,5 +248,5 @@
         float x = model->params->data.F32[PM_PAR_XPOS];
         float y = model->params->data.F32[PM_PAR_YPOS];
-        psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_U8(markVal));
+        psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_IMAGE_MASK(markVal));
     }
 
@@ -254,5 +254,5 @@
     psF32 **image  = readout->image->data.F32;
     psF32 **weight = readout->weight->data.F32;
-    psU8  **mask   = readout->mask->data.U8;
+    psImageMaskType  **mask   = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA;
 
     double w, x, y, x2, xy, y2, xc, yc, wt, f, fo, fx, fy;
@@ -288,5 +288,5 @@
 
     // turn off MARK for all image pixels
-    psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_U8(markVal));
+    psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_IMAGE_MASK(markVal));
 
     // set the Border T elements
Index: /branches/eam_branch_20081230/psphot/src/psphotGuessModels.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotGuessModels.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotGuessModels.c	(revision 21087)
@@ -40,9 +40,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
@@ -177,6 +177,6 @@
     pmPSF *psf = args->psf;
     psRegion *region = args->region;
-    psMaskType maskVal = args->maskVal;
-    psMaskType markVal = args->markVal;
+    psImageMaskType maskVal = args->maskVal;
+    psImageMaskType markVal = args->markVal;
 
     int nSrc = 0;
Index: /branches/eam_branch_20081230/psphot/src/psphotIsophotal.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotIsophotal.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotIsophotal.c	(revision 21087)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
+bool psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
 
   assert (source->extpars);
Index: /branches/eam_branch_20081230/psphot/src/psphotKron.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotKron.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotKron.c	(revision 21087)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotKron (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
+bool psphotKron (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
 
   psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n");
Index: /branches/eam_branch_20081230/psphot/src/psphotMagnitudes.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotMagnitudes.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotMagnitudes.c	(revision 21087)
@@ -17,9 +17,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotMakeGrowthCurve.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotMakeGrowthCurve.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotMakeGrowthCurve.c	(revision 21087)
@@ -11,9 +11,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotMakeResiduals.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotMakeResiduals.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotMakeResiduals.c	(revision 21087)
@@ -1,9 +1,11 @@
 # include "psphotInternal.h"
 
-bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal) {
+XXX this function is probably broken: fmasks is confused between Image and Vector.  it is used by psVectorStats, so it must be Vector, but 
+  is populated by mflux, which seems to be Image..
+bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal) {
 
     bool status, isPSF;
     double flux, dflux;
-    psU8 mflux;
+    psImageMaskType mflux;
 
     psTimerStart ("psphot.residuals");
@@ -69,5 +71,5 @@
     // - set output pixel, weight, and mask
 
-    // XXX need to set these correctly!!
+    XXX need to set these correctly based on the RECIPE values
     const int badMask = 1;              // mask bits
     const int poorMask = 2;             //       from psImageInterpolate
@@ -95,5 +97,5 @@
         psImage *image  = psImageCopy (NULL, source->pixels,   PS_TYPE_F32);
         psImage *weight = psImageCopy (NULL, source->weight,   PS_TYPE_F32);
-        psImage *mask   = psImageCopy (NULL, source->maskView, PS_TYPE_U8);
+        psImage *mask   = psImageCopy (NULL, source->maskView, PS_TYPE_IMAGE_MASK);
         pmModelSub (image, mask, model, PM_MODEL_OP_FUNC, maskVal);
 
@@ -131,5 +133,5 @@
     psVector *fluxes  = psVectorAlloc (input->n, PS_TYPE_F32);
     psVector *dfluxes = psVectorAlloc (input->n, PS_TYPE_F32);
-    psVector *fmasks  = psVectorAlloc (input->n, PS_TYPE_U8);
+    psVector *fmasks  = psVectorAlloc (input->n, PS_TYPE_VECTOR_MASK);
 
     // statistic to use to determine baseline for clipping
@@ -166,14 +168,14 @@
                     // This pixel is off the image
                     offImage = true;
-                    fmasks->data.U8[i] = 1;
+                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
                     // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);
                 }
                 fluxes->data.F32[i] = flux;
                 dfluxes->data.F32[i] = dflux;
-                fmasks->data.U8[i] = mflux;
+                fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
                 if (isnan(flux)) {
-                    fmasks->data.U8[i] = 1;
-                }
-                if (fmasks->data.U8[i] == 0) {
+                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
+                }
+                if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
                     nGoodPixel ++;
                 }
@@ -186,5 +188,5 @@
                 resid->Rx->data.F32[oy][ox] = 0.0;
                 resid->Ry->data.F32[oy][ox] = 0.0;
-                resid->mask->data.U8[oy][ox] = 1;
+                resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = 1;
                 continue;
             }
@@ -204,7 +206,7 @@
                 // make this a user option
                 if (swing > nSigma) {
-                    fmasks->data.U8[i] = clippedMask;
-                }
-		if (!fmasks->data.U8[i]) nKeep++;
+                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask;
+                }
+		if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++;
             }
 
@@ -220,8 +222,8 @@
 
                 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) {
-                  resid->mask->data.U8[oy][ox] = 1;
-                }
-
-		// fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.U8[oy][ox]);
+                  resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = 1;
+                }
+
+		// fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox]);
 
             } else {
@@ -230,5 +232,5 @@
                 psVectorInit(B, 0.0);
                 for (int i = 0; i < fluxes->n; i++) {
-                    if (fmasks->data.U8[i]) continue;
+                    if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
                     B->data.F64[0] += fluxes->data.F32[i]/dfluxes->data.F32[i];
                     B->data.F64[1] += fluxes->data.F32[i]*xC->data.F32[i]/dfluxes->data.F32[i];
@@ -260,8 +262,8 @@
 
                 float dRo = sqrt(A->data.F32[0][0]);
-		// fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.U8[oy][ox]);
+		// fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox]);
 
                 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*dRo/sqrt(nKeep)) {
-                  resid->mask->data.U8[oy][ox] = 1;
+                  resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = 1;
                 }
                 //resid->weight->data.F32[oy][ox] = XXX;
Index: /branches/eam_branch_20081230/psphot/src/psphotMaskReadout.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotMaskReadout.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotMaskReadout.c	(revision 21087)
@@ -9,9 +9,9 @@
     // XXX drop the write to recipe and move config into psphotRoughClass?
     // XXX alternatively, define a function to set the psphot recipe masks
-    psMaskType maskSat  = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
-    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
+    psImageMaskType maskSat  = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
+    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
 
-    psMaskType maskBad  = pmConfigMaskGet("BAD", config); // Mask value for bad pixels
-    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
+    psImageMaskType maskBad  = pmConfigMaskGet("BAD", config); // Mask value for bad pixels
+    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
 
     // generate mask & weight images if they don't already exit
Index: /branches/eam_branch_20081230/psphot/src/psphotModelBackground.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotModelBackground.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotModelBackground.c	(revision 21087)
@@ -23,5 +23,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotModelTest.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotModelTest.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotModelTest.c	(revision 21087)
@@ -13,9 +13,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotModelWithPSF.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotModelWithPSF.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotModelWithPSF.c	(revision 21087)
@@ -20,5 +20,5 @@
         paramMask = constraint->paramMask;
         if (paramMask != NULL) {
-            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
+	  PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_TYPE, false);
             PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
         }
@@ -145,10 +145,10 @@
 	psImageInit (covar, 0.0);
 	for (int j = 0, J = 0; j < params->n; j++) {
-	    if (paramMask && (paramMask->data.U8[j])) {
+	    if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
 		covar->data.F32[j][j] = 1.0;
 		continue;
 	    }
 	    for (int k = 0, K = 0; k < params->n; k++) {
-		if (paramMask && (paramMask->data.U8[k])) continue;
+		if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
 		covar->data.F32[j][k] = Alpha->data.F32[J][K];
 		K++;
@@ -197,5 +197,5 @@
     PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
     if (paramMask) {
-        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
+        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
     }
 
@@ -224,5 +224,5 @@
 	    // XXX probably should not skipped masked points: 
 	    // XXX skip if convolution of unmasked pixels will not see this pixel
-            // if (source->maskObj->data.U8[i][j]) {
+            // if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
 	    // continue;
 	    // }
@@ -246,5 +246,5 @@
 
 	    for (int n = 0; n < params->n; n++) {
-		if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
+		if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; }
 		psImage *dmodel = pcm->dmodels->data[n];
 		dmodel->data.F32[i][j] = deriv->data.F32[n];
@@ -285,5 +285,5 @@
 	    // XXX are we doing the right thing with the mask?
             // skip masked points
-            if (source->maskObj->data.U8[i][j]) {
+            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
                 continue;
             }
@@ -308,9 +308,9 @@
 	    // alpha & beta only contain unmasked elements 
 	    for (int n1 = 0, N1 = 0; n1 < params->n; n1++) {
-		if ((paramMask != NULL) && (paramMask->data.U8[n1])) continue;
+		if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n1])) continue;
 		psImage *dmodel = pcm->dmodelsConv->data[n1];
 		float weight = dmodel->data.F32[i][j] * yweight;
 		for (int n2 = 0, N2 = 0; n2 <= n1; n2++) {
-		    if ((paramMask != NULL) && (paramMask->data.U8[n2])) continue;
+		    if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n2])) continue;
 		    dmodel = pcm->dmodelsConv->data[n2];
 		    alpha->data.F32[N1][N2] += weight * dmodel->data.F32[i][j];
@@ -357,5 +357,5 @@
     for (psS32 n = 0; n < params->n; n++) {
 	pcm->dmodels->data[n] = NULL;
-	if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
+	if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; }
 	pcm->dmodels->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
     }
@@ -366,5 +366,5 @@
     for (psS32 n = 0; n < params->n; n++) {
 	pcm->dmodelsConv->data[n] = NULL;
-	if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
+	if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; }
 	pcm->dmodelsConv->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
     }
Index: /branches/eam_branch_20081230/psphot/src/psphotMosaicChip.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotMosaicChip.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotMosaicChip.c	(revision 21087)
@@ -25,5 +25,5 @@
     }
 
-    psMaskType blankMask = pmConfigMaskGet("BLANK", config);
+    psImageMaskType blankMask = pmConfigMaskGet("BLANK", config);
 
     // mosaic the chip, forcing a deep copy (resulting images are not subimages)
Index: /branches/eam_branch_20081230/psphot/src/psphotOutput.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotOutput.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotOutput.c	(revision 21087)
@@ -74,5 +74,5 @@
         for (int j = 0; j < source->pixels->numCols; j++) {
             // skip masked points
-            if (source->maskObj->data.U8[i][j]) {
+            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
                 continue;
             }
@@ -87,5 +87,5 @@
                      source->pixels->data.F32[i][j],
                      1.0 / source->weight->data.F32[i][j],
-                     source->maskObj->data.U8[i][j]);
+                     source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]);
         }
     }
@@ -237,5 +237,5 @@
 
 // XXX add args as needed
-bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psMaskType maskVal, psMaskType markVal) {
+bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal) {
 
     psphotSaveImage (NULL, readout->image,  "rawstars.fits");
@@ -243,5 +243,5 @@
     for (int i = 0; i < try->sources->n; i++) {
 	// masked for: bad model fit, outlier in parameters
-	if (try->mask->data.U8[i] & PSFTRY_MASK_ALL)
+	if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL)
 	    continue;
 
@@ -256,5 +256,5 @@
 	psImageKeepCircle (source->maskObj, x, y, radius, "OR", markVal);
 	pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal);
-	psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_U8(markVal));
+	psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_IMAGE_MASK(markVal));
     }
 
@@ -264,5 +264,5 @@
 
 	// masked for: bad model fit, outlier in parameters
-	if (try->mask->data.U8[i] & PSFTRY_MASK_ALL) continue;
+	if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue;
 
 	pmSource *source = try->sources->data[i];
Index: /branches/eam_branch_20081230/psphot/src/psphotPSFConvModel.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotPSFConvModel.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotPSFConvModel.c	(revision 21087)
@@ -9,5 +9,5 @@
 // modelConv to contain the fitted parameters, and the modelFlux to contain the 
 // convolved model image.
-pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize) {
+pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) {
     
     // maskVal is used to test for rejected pixels, and must include markVal
@@ -72,5 +72,5 @@
     // create the minimization constraints
     psMinConstraint *constraint = psMinConstraintAlloc();
-    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
+    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
     constraint->checkLimits = modelConv->modelLimits;
 
@@ -79,5 +79,5 @@
     int nParams = params->n - 1;
     psVectorInit (constraint->paramMask, 0);
-    constraint->paramMask->data.U8[PM_PAR_SKY] = 1;
+    constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
 
     // force the floating parameters to fall within the contraint ranges
@@ -97,5 +97,5 @@
             fprintf (stderr, "%f ", params->data.F32[i]);
         }
-        if ((constraint->paramMask != NULL) && constraint->paramMask->data.U8[i])
+        if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i])
             continue;
         dparams->data.F32[i] = sqrt(covar->data.F32[i][i]);
Index: /branches/eam_branch_20081230/psphot/src/psphotPetrosian.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotPetrosian.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotPetrosian.c	(revision 21087)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
+bool psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
 
   bool status;
Index: /branches/eam_branch_20081230/psphot/src/psphotRadialPlot.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotRadialPlot.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotRadialPlot.c	(revision 21087)
@@ -60,5 +60,5 @@
     for (int iy = 0; iy < source->pixels->numRows; iy++) {
 	for (int ix = 0; ix < source->pixels->numCols; ix++) {
-	    if (source->maskObj->data.U8[iy][ix]) {
+	    if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) {
 		rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ;
 		fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]);
Index: /branches/eam_branch_20081230/psphot/src/psphotRadialProfile.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotRadialProfile.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotRadialProfile.c	(revision 21087)
@@ -17,5 +17,5 @@
 }
 
-bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
+bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
 
     // allocate pmSourceExtendedParameters, if not already defined
@@ -54,5 +54,5 @@
     for (int iy = 0; iy < source->pixels->numRows; iy++) {
         for (int ix = 0; ix < source->pixels->numCols; ix++) {
-            if (source->maskObj->data.U8[iy][ix]) continue;
+            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) continue;
             radius->data.F32[n] = hypot (ix - Xo, iy - Yo) ;
             flux->data.F32[n]   = source->pixels->data.F32[iy][ix];
Index: /branches/eam_branch_20081230/psphot/src/psphotRadiusChecks.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotRadiusChecks.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotRadiusChecks.c	(revision 21087)
@@ -19,5 +19,5 @@
 
 // call this function whenever you (re)-define the PSF model
-bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal)
+bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal)
 {
     psF32 *PAR = model->params->data.F32;
@@ -50,5 +50,5 @@
 }
 
-bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR) {
+bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal, float dR) {
 
     psF32 *PAR = model->params->data.F32;
@@ -86,5 +86,5 @@
 
 // call this function whenever you (re)-define the EXT model
-bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal) {
+bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) {
 
     psF32 *PAR = model->params->data.F32;
Index: /branches/eam_branch_20081230/psphot/src/psphotReplaceUnfit.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotReplaceUnfit.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotReplaceUnfit.c	(revision 21087)
@@ -2,5 +2,5 @@
 
 // replace the flux for sources which failed
-bool psphotReplaceUnfitSources (psArray *sources, psMaskType maskVal) {
+bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal) {
 
     pmSource *source;
@@ -31,5 +31,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
@@ -55,5 +55,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
@@ -72,5 +72,5 @@
 
 // add source, if the source has been subtracted; do not modify state
-bool psphotAddWithTest (pmSource *source, bool useState, psMaskType maskVal) {
+bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
 
     // what is current state? (true : add; false : sub)
@@ -83,5 +83,5 @@
 
 // sub source, if the source has been added; do not modify state
-bool psphotSubWithTest (pmSource *source, bool useState, psMaskType maskVal) {
+bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
 
     // what is current state? (true : sub; false : add)
@@ -94,5 +94,5 @@
 
 // add or sub source to match recorded state: supply current state as true (add) or false (sub)
-bool psphotSetState (pmSource *source, bool curState, psMaskType maskVal) {
+bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal) {
 
     // what is desired state? (true : add; false : sub)
Index: /branches/eam_branch_20081230/psphot/src/psphotRoughClass.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotRoughClass.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotRoughClass.c	(revision 21087)
@@ -57,5 +57,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskSat = psMetadataLookupU8(&status, recipe, "MASK.SAT"); // Mask value for bad pixels
+    psImageMaskType maskSat = psMetadataLookupImageMask(&status, recipe, "MASK.SAT"); // Mask value for bad pixels
     assert (maskSat);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotSetMaskBits.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSetMaskBits.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSetMaskBits.c	(revision 21087)
@@ -10,6 +10,6 @@
 bool psphotSetMaskBits (pmConfig *config) {
 
-    psMaskType maskValue;
-    psMaskType markValue;
+    psImageMaskType maskValue;
+    psImageMaskType markValue;
 
     if (!pmConfigMaskSetBits (&maskValue, &markValue, config)) {
@@ -26,6 +26,6 @@
 
     // set maskValue and markValue in the psphot recipe
-    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markValue);
-    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskValue);
+    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markValue);
+    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskValue);
 
     return true;
Index: /branches/eam_branch_20081230/psphot/src/psphotSignificanceImage.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSignificanceImage.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSignificanceImage.c	(revision 21087)
@@ -4,5 +4,5 @@
 // (S/N)^2.  If FWMH_X,Y have been recorded, use them, otherwise use PEAKS_SMOOTH_SIGMA for the
 // smoothing kernel.
-psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal) {
+psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal) {
 
     float SIGMA_SMTH, NSIGMA_SMTH;
@@ -110,5 +110,5 @@
         for (int i = 0; i < smooth_im->numCols; i++) {
             float value = smooth_im->data.F32[j][i];
-            if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data.U8[j][i] & maskVal)) {
+            if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal)) {
                 smooth_im->data.F32[j][i] = 0.0;
             } else {
Index: /branches/eam_branch_20081230/psphot/src/psphotSkyReplace.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSkyReplace.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSkyReplace.c	(revision 21087)
@@ -17,5 +17,5 @@
     // select the corresponding images
     psF32 **image = readout->image->data.F32;
-    psU8  **mask  = readout->mask->data.U8;
+    psImageMaskType  **mask  = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA;
     psF32 **back  = background->image->data.F32;
 
Index: /branches/eam_branch_20081230/psphot/src/psphotSourceFits.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSourceFits.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSourceFits.c	(revision 21087)
@@ -21,5 +21,5 @@
 }
 
-bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
+bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
 
     float x, y, dR;
@@ -146,5 +146,5 @@
 }
 
-bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
+bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
 
     double chiTrend;
@@ -207,5 +207,5 @@
 }
 
-bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
+bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
 
     bool okEXT, okDBL;
@@ -317,5 +317,5 @@
 
 // fit a double PSF source to an extended blob
-psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal) {
+psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) {
 
     float dx, dy;
@@ -369,5 +369,5 @@
 }
 
-pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal) {
+pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) {
 
     NfitEXT ++;
Index: /branches/eam_branch_20081230/psphot/src/psphotSourcePlots.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSourcePlots.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSourcePlots.c	(revision 21087)
@@ -7,5 +7,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotSourceSize.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSourceSize.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSourceSize.c	(revision 21087)
@@ -3,8 +3,8 @@
 
 static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask,
-                                psMaskType maskVal, const pmModel *model, float Ro);
-
-bool psphotMaskCosmicRay_Old (pmSource *source, psMaskType maskVal, psMaskType crMask);
-bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psMaskType maskVal, psMaskType crMask);
+                                psImageMaskType maskVal, const pmModel *model, float Ro);
+
+bool psphotMaskCosmicRay_Old (pmSource *source, psImageMaskType maskVal, psImageMaskType crMask);
+bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psImageMaskType maskVal, psImageMaskType crMask);
 
 // we need to call this function after sources have been fitted to the PSF model and
@@ -21,9 +21,9 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
     // bit to mask the cosmic-ray pixels
-    psMaskType crMask  = pmConfigMaskGet("CR", config); // Mask value for cosmic rays
+    psImageMaskType crMask  = pmConfigMaskGet("CR", config); // Mask value for cosmic rays
 
     float CR_NSIGMA_LIMIT = psMetadataLookupF32 (&status, recipe, "PSPHOT.CR.NSIGMA.LIMIT");
@@ -63,5 +63,5 @@
         psF32 **resid  = source->pixels->data.F32;
         psF32 **weight = source->weight->data.F32;
-        psU8 **mask    = source->maskObj->data.U8;
+        psImageMaskType **mask    = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;
 
         // check for extendedness: measure the delta flux significance at the 1 sigma contour
@@ -191,5 +191,5 @@
 // deviations?
 static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask,
-                                psMaskType maskVal, const pmModel *model, float Ro)
+                                psImageMaskType maskVal, const pmModel *model, float Ro)
 {
     psF32 *PAR = model->params->data.F32; // Model parameters
@@ -260,5 +260,5 @@
 }
 
-bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psMaskType maskVal, psMaskType crMask) {
+bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psImageMaskType maskVal, psImageMaskType crMask) {
 
     // replace the source flux
@@ -294,5 +294,5 @@
 	
 	for (int ix = xs; ix < xe; ix++) {
-	    mask->data.U8[iy][ix] |= crMask;
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;
 	}
     }
@@ -300,5 +300,5 @@
 }
 
-bool psphotMaskCosmicRay_Old (pmSource *source, psMaskType maskVal, psMaskType crMask) {
+bool psphotMaskCosmicRay_Old (pmSource *source, psImageMaskType maskVal, psImageMaskType crMask) {
 
     source->mode |= PM_SOURCE_MODE_CR_LIMIT;
@@ -320,5 +320,5 @@
 	float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]);
 	if (SN > SN_LIMIT) {
-	    mask->data.U8[yo][ix] |= crMask;
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask;
 	}
     }
@@ -326,5 +326,5 @@
 	float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]);
 	if (SN > SN_LIMIT) {
-	    mask->data.U8[yo][ix] |= crMask;
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask;
 	}
     }
@@ -339,10 +339,10 @@
 
 	    bool valid = false;
-	    valid |= (mask->data.U8[iy+1][ix] & crMask);
-	    valid |= (ix > 0) ? (mask->data.U8[iy+1][ix-1] & crMask) : 0;
-	    valid |= (ix <= mask->numCols) ? (mask->data.U8[iy+1][ix+1] & crMask) : 0;
+	    valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix] & crMask);
+	    valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix-1] & crMask) : 0;
+	    valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix+1] & crMask) : 0;
 
 	    if (!valid) continue;
-	    mask->data.U8[iy][ix] |= crMask;
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;
 	}
     }
@@ -355,10 +355,10 @@
 
 	    bool valid = false;
-	    valid |= (mask->data.U8[iy-1][ix] & crMask);
-	    valid |= (ix > 0) ? (mask->data.U8[iy-1][ix-1] & crMask) : 0;
-	    valid |= (ix <= mask->numCols) ? (mask->data.U8[iy-1][ix+1] & crMask) : 0;
+	    valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix] & crMask);
+	    valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix-1] & crMask) : 0;
+	    valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix+1] & crMask) : 0;
 
 	    if (!valid) continue;
-	    mask->data.U8[iy][ix] |= crMask;
+	    mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;
 	}
     }
Index: /branches/eam_branch_20081230/psphot/src/psphotSourceStats.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSourceStats.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSourceStats.c	(revision 21087)
@@ -10,9 +10,9 @@
 
     // bit-masks to test for good/bad pixels
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     assert (maskVal);
 
     // bit-mask to mark pixels not used in analysis
-    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
+    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     assert (markVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotSubtractBackground.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotSubtractBackground.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotSubtractBackground.c	(revision 21087)
@@ -28,5 +28,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
Index: /branches/eam_branch_20081230/psphot/src/psphotTestPSF.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotTestPSF.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotTestPSF.c	(revision 21087)
@@ -111,5 +111,5 @@
         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", markVal);
         status = pmSourceFitModel (source, model, PM_SOURCE_FIT_EXT);
-        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(markVal));
+        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_IMAGE_MASK(markVal));
 
 	// write fitted parameters to file
Index: /branches/eam_branch_20081230/psphot/src/psphotTestSourceOutput.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotTestSourceOutput.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotTestSourceOutput.c	(revision 21087)
@@ -80,5 +80,5 @@
 		float oy = yBin*(iy + 0.5 + image->row0 - yCenter) + yResidCenter;
 
-		psU8 mflux = 0;
+		psImageMaskType mflux = 0;
 		double Fo = 0.0;
 		double Fx = 0.0;
Index: /branches/eam_branch_20081230/psphot/src/psphotVisual.c
===================================================================
--- /branches/eam_branch_20081230/psphot/src/psphotVisual.c	(revision 21086)
+++ /branches/eam_branch_20081230/psphot/src/psphotVisual.c	(revision 21087)
@@ -51,5 +51,5 @@
 	ALLOCATE (image.data2d[iy], float, image.Nx);
 	for (int ix = 0; ix < image.Nx; ix++) {
-	    image.data2d[iy][ix] = inImage->data.U8[iy][ix];
+	    image.data2d[iy][ix] = inImage->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix];
 	}
     }
@@ -813,5 +813,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
@@ -973,5 +973,5 @@
 
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
@@ -1097,5 +1097,5 @@
 }
 
-bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psMaskType maskVal) {
+bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal) {
 
     Graphdata graphdata;
@@ -1118,5 +1118,5 @@
     for (int iy = 0; iy < source->pixels->numRows; iy++) {
 	for (int ix = 0; ix < source->pixels->numCols; ix++) {
-	    if (source->maskObj->data.U8[iy][ix]) {
+	    if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) {
 		// rb->data.F32[nb] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ;
 		rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ;
@@ -1227,5 +1227,5 @@
     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     bool status;
-    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     assert (maskVal);
 
