String-based data URIs

Refactors the API and adds support for string-based URIs. i.e. this avoids doing base64 encoding for data which is already ASCII and string-based.