def write(self, write_data):
    if hasattr(write_data, 'decode'):
        return self.temp.write(write_data)
    return self.temp.write(write_data.encode())
def write(self, write_data):
    if hasattr(write_data, 'decode'):
        return self.temp.write(write_data)
    return self.temp.write(write_data.encode())