Apply changes removed rebasing pullreq #679.

https://github.com/leapcode/bitmask_client/pull/679/files
pep8 fixes
Use custom `mkdir` to create the tree if needed.