Fixes installer leftovers in the Joomla tmp folder after unsuccessful installation with wrong file type

**This PR includes already https://github.com/joomla/joomla-cms/pull/2143 so should be MERGED AFTER https://github.com/joomla/joomla-cms/pull/2143 .**

To test:
1. Check that your joomla tmp folder is empty
2. install an extension by all 4 methods and verify for each that it is still installed correctly, and that there are still no leftovers in tmp
3. Try insatlling a pdf file and also Google Maps plugin (it's on main dashboard, and has no 3.2-version yet) and verify that they are not installed, but also that now with the patch there are no leftovers in the tmp folder.