made compatible with python3 (with PIL backend)