def save_file(self, outputfilename = self.image_filename):
self.file.read(outputfilename)
....
gives NameError: name 'self' is not defined
in the first line. It seems that Python doesn't accept it. How can I rewrite the code so it doesn't raise an exception?