Fix memory leaks in the test suite.

This works by avoiding storing a reference to the figure in the
"do_test" enclosure in the image_comparison decorator.  nose keeps a
reference to all of its test functions, and thereby holds on to every
figure in every test that uses the image_comparison decorator (which is
most).  Instead of using the figure in the outer scope, this just uses
the figure number, and then it's looked up when the test function is
actually run.

Also adds gc.collect() so we can ensure there are zero figures in memory
at the start of each test.  Probably not strictly necessary, but it
makes analysing memory usage easier.