def write_chunk(self, x, z, nbt_file):
        data = BytesIO()
        nbt_file.write_file(buffer=data) # render to buffer; uncompressed
        self.write_blockdata(x, z, data.getvalue())
Pack the NBT file as binary data, and write to file in a compressed format.
dataset/ETHPy150Open twoolie/NBT/nbt/region.py/RegionFile.write_chunk