Fixes #112 check_encoding() can cause timeouts

#112