add the method to write data to outputstream