Custom output stream implementation to avoid need to create byte streams
and arrays.