Fix for broken media uploads

Media uploads were failing if the image needed to be downloaded first. The cause was that the media item's mimeType was not being set properly, which would cause WP to reject the file.

Also fixed up a few display issues in MediaGridAdapter, and moved some methods to the MediaUtils class so they could easily be reused.

Fixes #1081