Correctly decode stream; make pipable to python