added saving to stream for pure python