Improved error handling in imgur upload process.

It was possible for http.request to throw an exception if a timeout
was reached. Also, the imgur API sometimes returns non-JSON data
when the upload failed.