Made some changes to comply with PEP8, standardised naming and added a r...

...andom string generator to create a filename if one isn't supplied. I also removed tabs and replaced them with spaces.