Adhere to ISO8601 strict. Millisecond precision only on datetime.

Javascript Date and most js date libraries only adhere to ISO8601 strict, which means either second precision or millisecond precision only. However, ``datetime.isoformat()`` will return microsecond precision if available. This fix is taken from `django.core.serializers.json.DjangoJSONEncoder` -  https://github.com/django/django/blob/master/django/core/serializers/json.py