Move dupe code in loadFromBase64 and loadFromData into separate function.