Update conventions.py

Changed datetime check, copied encoding.