Fix null termination in base64 encoding