Base64 encode binary data before logging

Both the logger and the data collector for the profiler would output raw
binary data. The logger would fail due to UTF-8 warnings when doing
json_encode and the profiler queries would fail in Twig when displaying
them in mongodb.html.twig.