Python implementation: use io.BytesIO.getvalue instead of read