<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_fits(self, data, outfile, extname="SKYMAP", clobber=True):
 """ Write input data to a FITS file data : The data begin stored outfile : The name of the output file extname : The HDU extension name clobber : True -> overwrite existing files """

        hdu_prim = fits.PrimaryHDU()
        hdu_hpx = self.make_hdu(data, extname=extname)
        hl = [hdu_prim, hdu_hpx]
        if self.conv.energy_hdu == 'EBOUNDS':
            hdu_energy = self.make_energy_bounds_hdu()
        elif self.conv.energy_hdu == 'ENERGIES':
            hdu_energy = self.make_energies_hdu()
        if hdu_energy is not None:
            hl.append(hdu_energy)
        hdulist = fits.HDUList(hl)
        hdulist.writeto(outfile, overwrite=clobber)