thumbnail: Clean up path generation code

Put the path calculation code in one spot.

https://bugzilla.gnome.org/show_bug.cgi?id=684026
thumbnail: Move thumbnail generation/saving to a few helper functions

Another cleanup in preparation for a new "simple" thumbnail API.

https://bugzilla.gnome.org/show_bug.cgi?id=684026