#521 remove python 2.4 and 2.5 support
(#521) import ast/json assuming python >= 2.6
#521: assume python >= 2.6 and use tempfile.NamedTemporaryFile(..., delete=False)
more logical indentation
#521: use try/except/finally in a single logical block
#521: use contextlib.closing() - fixes all ResourceWarnings during tests
refactoring