Fix Encoding error for shutil

use correct internal de- and encoding, rename "dir" variable to "pdir"