Fixing crash when cancelling image upload in chrome

This fixes a crash that can occur in Chrome (and possibly other browsers that aren't Firefox) when you upload a badge image, then click the button to upload a different one, and then click cancel.

Addresses #405