we should also catch the TypeError.
we should also catch the TypeError.

since the file write function will throw TypeError if the contents is
None.
there's one customer reported this.

thomas1206/WALinuxAgent,karataliu/WALinuxAgent,karataliu/WALinuxAgent,thomas1206/WALinuxAgent