Utility method to write nanopubs to stream