set default MASTERDIR
try adhere to PEP 8 Style Guide for Python Code
use os.path.splitext() to get filename extension
use operator +=
terse path bug fixed