Fix potential memory leak in src/Format.cpp

(Merging pull request #233)
Fix potential memory leaks.

(Merging pull request #234, amended by jacksonmj: some leaks already fixed in develop branch.)