Add handling of base64 image data and other other minor tweaks

Also includes general cleanup and better logging (only uses `IF.emoji.error` for actual errors), and fixes the tests, so we can run `npm test` during deployment.