<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert(self, format="png", **kwargs):
 """ png, ps, pdf, gif, jpg, svg returns image in format as bytes """

        if format.upper() in cairosvg.SURFACES:
            surface = cairosvg.SURFACES[format.upper()]
        else:
            raise Exception("'%s' image format unavailable: use one of %s" %
                            (format.upper(), list(cairosvg.SURFACES.keys())))
        return surface.convert(bytestring=str(self), **kwargs)