Write/create/truncate prototxt when saving to fix #341

WriteProtoToTextFile now saves the prototxt whether or not the file
already exists and sets the permissions to owner read/write and group +
other read.

Thanks @beam2d and @chyh1990 for pointing out the open modes bug.
fix workaround in net prototxt upgrade
Merge pull request #417 from shelhamer/create-and-write-proto

Write/create/truncate prototxt when saving to fix #341