code: def _write_mosaic(self, key, outfile):
          
          maxsize = self.settings.get('max_mosaic_size', 1e8)  # Default 10k x 10k
          channel = self.fv.get_channel(self.chname)
          image = channel.datasrc[key]
  
          # Prevent writing very large mosaic
          if (image.width * image.height) > maxsize:
              s = 'Mosaic too large to be written {0}'.format(image.shape)
              self.w.status.set_text(s)
              self.logger.error(s)
              return
  
          # Insert mosaic data and header into output HDU
          hdu = fits.PrimaryHDU(image.get_data())
          self._write_header(image, hdu)
  
          # Write history to PRIMARY
          self._write_history(key, hdu)
  
          # Write to file
          if minversion(astropy, '1.3'):
              hdu.writeto(outfile, overwrite=True)
          else:
              hdu.writeto(outfile, clobber=True)
docs: Write out mosaic data (or any new data generated within Ginga)
          to single-extension FITS.