'Return a string encoding of the page header and data.
A ValueError is raised if the data is too big to fit in a
single page.'

def write(self):

    data = [struct.pack('<4sBBqIIi', 'OggS', self.version, self.__type_flags, self.position, self.serial, self.sequence, 0)]
    lacing_data = []
    for datum in self.packets:
        (quot, rem) = divmod(len(datum), 255)
        lacing_data.append((('\xff' * quot) + chr_(rem)))
    lacing_data = ''.join(lacing_data)
    if ((not self.complete) and lacing_data.endswith('\x00')):
        lacing_data = lacing_data[:(-1)]
    data.append(chr_(len(lacing_data)))
    data.append(lacing_data)
    data.extend(self.packets)
    data = ''.join(data)
    crc = ((~ zlib.crc32(data.translate(cdata.bitswap), (-1))) & 4294967295)
    crc = cdata.to_uint_be(crc).translate(cdata.bitswap)
    data = ((data[:22] + crc) + data[26:])
    return data
