3.x backport - ByteArrayObjectDataOutput when writing to an explicit location

Backport of #2726