resolve #4390

resolve #4390
- compatible with py3
- use argparse to replace optparse, optparse module is deprecated.