Avoid tracebacks in certain caching edge cases

This fixes #4174.

When salt tries to cache a file and its cache destination already exists
(and is a directory), recursively remove the directory before caching
the file.

Inversely, when salt tries to cache a file/directory and a directory in
the cachedir that salt is trying to create exists (and is a file),
remove the cached file first before attempting to create the directory.

Also, made PEP8 fixes to keep pylint happy.