Use Base64.strict_encode64 to avoid invalid newlines