Cleanup the mime type code

This adds some documentation and fixes the file and variable naming.

It also has a few bug fixes and improvements:

* The previous implementation was not choosing the preferred mime
  type, only the first one in the array of mime types.  This sorts
  the array by priority before picking the first one, similar to
  how the mime-types gem works.  I'm not sure why mime-types doesn't
  store the data in a sorted order.

* It sorts the hashes when writing the mime_types/cache file, so
  running the copy_mime rake task multiple times is now idempotent.