Fix base64 encoding with streams

Fixes [gh-207].