Fix overwriting, when installing PKG files

Now properly removes the directory and tries to continue installation.
Use std::string for installing PKG files

Also now only refreshes, when it could open the PKG file.
Merge pull request #773 from tambry/OverwriteFix

Fix overwriting, when installing PKG files