Use SafeDump to dump YAML files

Prepare for switch to Python 3, which cannot read some unsafe YAML files written by Python 2.