Fix multithread issue in localmsg API

If not, files with the same name will be fetched by different threads, which means if one of the thread remove the generated image file, when the other trying to remove the scaled file, it will fail.