'Encode `data`, write it to a single file, and return it.'

def write(self, data):

    output = self.encode(data)
    if (not self.opened):
        self.open()
    try:
        self.destination.write(output)
    finally:
        if self.autoclose:
            self.close()
    return output
