pack/unpack chunk identifiers more efficiently, fix py3