Refactor to use promises with the base64 image conversion.