Prevent concurrent writings of the same file
fix #3540: corrupted images on image tab