save current date-time when saving messages

reorder imports, some PEP-8 changes
fix indentation problem