change directory rights
remove toctou writing image file