Encoding for streams. Closes #10.