<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_file(self, filename):
 """Export to image file. Parameters filename : string Location to write to. Returns ------- self """


        img = self.to_image()
        img.save(filename, optimize=True)
        return self