write correct dataSize to output stream