Replaced self.stdout.encoding with sys.stdout.encoding