Fixed multithread issue when creating image directories.   #692