code: def buildMask(self,chip,bits=0,write=False):
          
          dqarr = self.getData(exten=self.maskExt+','+str(chip))
          dqmask = buildmask.buildMask(dqarr,bits)
  
          if write:
              phdu = fits.PrimaryHDU(data=dqmask,header=self._image[self.maskExt,chip].header)
              dqmask_name = self._image[self.scienceExt,chip].dqrootname+'_dqmask.fits'
              log.info('Writing out DQ/weight mask: %s' % dqmask_name)
              if os.path.exists(dqmask_name): os.remove(dqmask_name)
              phdu.writeto(dqmask_name)
              del phdu
              self._image[self.scienceExt,chip].dqmaskname = dqmask_name
              # record the name of this mask file that was created for later
              # removal by the 'clean()' method
              self._image[self.scienceExt,chip].outputNames['dqmask'] = dqmask_name
          del dqarr
          return dqmask
docs: Build masks as specified in the user parameters found in the
          configObj object.
  
          We should overload this function in the instrument specific
          implementations so that we can add other stuff to the badpixel
          mask? Like vignetting areas and chip boundries in nicmos which
          are camera dependent? these are not defined in the DQ masks, but
          should be masked out to get the best results in multidrizzle.