Using pathlib in code to simplify the code

Using pathlib in code to simplify the code. This is an okay lib to add as it's already accepted into Python-3.4 mainline, so later we don't really have to do any changes to migrate to it.