medialibrary: thumb: check fclose while saving
It should not be assumed that the thumbnail was saved properly when
fclose
fails.
The RAII wrapper here does not improve readability or shorten the code.
This MR supersede !4057 (closed) by working around the warning and handling the error at the same time.