Use yaml.safe_load instead of load.

yaml.load will execute arbitrary code.

Also use context managers to ensure files are closed

Change-Id: I704baa7916ee834c12821009d8e3029b1b8fa340
Merge "Use yaml.safe_load instead of load."