pack-objects: clean up write_object() a bit