Handle renaming on case-insensitive filesystems

A rename will fail on a filesystem that is case-insensitive, if the
filenames only differ by case. Work around this by moving to a temporary
file first, in the case that a rename fails because the target exists.

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