Stop app from generating image upon error

If there is no connection, or the key is invalid, exit immediately with
an error instead of generating a bad image. This makes it easier to run
automatically, even with a flaky connection like on a laptop without
worrying about getting a grayed out image.

It also shows a helpful message when problems show up in curl or with
the api.