Plug memory leaks

Based on a patch by Markus Peloquin <markus@cs.wisc.edu> from the
Musepack fork of cuetools.

http://trac.musepack.net/changeset/469