Clean up codec.{h,cc}.

There was a potential leak of a Codec object in the factory methods if
initialisation failed: the codec would not be placed in the scoped_ptr,
and thus never deleted. This patch fixes that, and also does a lot of
superficial cleanup of the codec files, fixing comment justification,
idiomatic use of Substitute() and BOOST_FOREACH, and other small things.

Change-Id: I53ca0ead8698185e1c398abf2770ef5fd8a45e34
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4072
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 7b7369fd83b4fd51ec0927a00491f5592974ca9e)
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4095