Fix support for image copy etc when using targetDirectory.