engine.set_status(): Use filename keyword instead of kwargs.
changelog: Fixes typo in save_document.
writer.py: Refactors safe_filename and fixes Python 2 support.