Migrate to Py3. Some fixes of encoding errors and date conversion.