Added ability to write model in OutputStream