The creation and modification dates are still changing. Can't you explicitly change them after the file is created? you anyways have the paths in a variable right? I went through the code but I am not so well at understnading.
Could you add a small feature to copy the modified date as well as created date from old image to new image? It will really be helpful.