Added data_uri option and improved error handling