Experiment with porting path handling to use pathlib.

The biggest impetus here is to allow Django integration without having
to copy and paste massive piles of code.