I am using a bytearray indeed with the writeshorts.
I had hoped to use amfphp to save them as blobs in a mysql database, but no matter what I tried it borked, so I make a bytearray, compress it and then turn it into a base64 string.

All up it takes a 60k file down to 1k which is pretty sweet.