code: def _tofile(self, fh, pam=False):
          
          fh.seek(0)
          fh.write(self._header(pam))
          data = self.asarray(copy=False)
          if self.maxval == 1:
              data = numpy.packbits(data, axis=-1)
          data.tofile(fh)
docs: Write Netbm file.