test_match.py: cut very long outputs
test_match.py: add new functions

* set_encoding()
* set_output_encoding()

Separate them from main().
test_match.py: support 'opt' and 'err' options
test_match.py: add many tests