Ensure that parent dir for known_hosts file exists

Fixes #4153. Also made pep8 fixes.
Merge pull request #4159 from terminalmage/issue4153

Ensure that parent dir for known_hosts file exists