Performance and command line update

I added automatic image resize so that it can run on really large images in a timely manner. I also fixed up the command line version so it uses argparse and has some prettier output.
@Drewsif 
Would you try on the following change? 
`_testfile()` and `_poolcallback()` change to top level function, and `if __name__ == '__main__':` change `def main()` .
(`import math` move to top level, too.)

ex)
```
import math
  :

def _testfile(...):
    ...

def _poolcallback(...):
    ...

def main():
    import argparse
    import os
        :

if __name__ == '__main__':
    main()
```