Update tesseract.py

improve exception handling