If you want to avoid being dependent on Pillow, you could use https://raw.github.com/drj11/pypng/main/code/png.py to read the rendered PNG and save BIP according to the format linked in my previous post. PyPNG might be slow, though. Be aware that you need to flip top to bottom, and you need premultiplied alpha (https://github.com/3dninjas/3dn-bip/blob/main/bip_converter/t3dn_bip_converter/convert.py#L33-L34).