fix some bugs in decode.py