code: def save_images(self):
          
          res_dict = self.treeview.get_selected()
          clobber = self.settings.get('clobber', False)
          self.treeview.clear_selection()  # Automatically disables Save button
  
          # If user gives empty string, no suffix.
          if self.suffix:
              sfx = '_' + self.suffix
          else:
              sfx = ''
  
          # Also include channel name in suffix. This is useful if user likes to
          # open the same image in multiple channels.
          if self.settings.get('include_chname', True):
              sfx += '_' + self.chname
  
          # Process each selected file. Each can have multiple edited extensions.
          for infile in res_dict:
              f_pfx = os.path.splitext(infile)[0]  # prefix
              f_ext = '.fits'  # Only FITS supported
              oname = f_pfx + sfx + f_ext
              outfile = os.path.join(self.outdir, oname)
  
              self.w.status.set_text(
                  'Writing out {0} to {1} ...'.format(shorten_name(infile, 10),
                                                      shorten_name(oname, 10)))
              self.logger.debug(
                  'Writing out {0} to {1} ...'.format(infile, oname))
  
              if os.path.exists(outfile) and not clobber:
                  self.logger.error('{0} already exists'.format(outfile))
                  continue
  
              bnch = res_dict[infile]
  
              if bnch.path is None or not os.path.isfile(bnch.path):
                  self._write_mosaic(f_pfx, outfile)
              else:
                  shutil.copyfile(bnch.path, outfile)
                  self._write_mef(f_pfx, bnch.extlist, outfile)
  
              self.logger.info('{0} written'.format(outfile))
  
          self.w.status.set_text('Saving done, see log')
docs: Save selected images.
  
          This uses Astropy FITS package to save the outputs no matter
          what user chose to load the images.