Fix base64 encoding with streams

Fixes [gh-207].
please respect the PSR-2 position for curly braces