Fix base64 encoding with streams

Fixes [gh-207].
@apinstein the main place where tests are run is on Travis, where the PHPUnit phar is already available. Given that requiring phpunit/phpunit actually requires 14 packages (and even 16 or 17 in the upcoming 4.4 version), avoiding it has a non-negligeable impact on the build time.

and anyway, ``*`` is not an acceptable version constraint