File handles are now properly closed.

Fixes #899.
Added support for non-diagonal zeros in Moran's I.

This issue came up during the biogeo project when there are identical samples in the distance matrix, which result in zeros that aren't isolated to the diagonal. R's Moran.I would error out on this input.

The fix is to substitute a very small number for the zeros in the matrix (since we can't use zero itself). @antgonza, @gregcaporaso, and I discussed this in detail on the private biogeo issue tracker.

These changes also add an explicit test for this case.
Merge pull request #900 from jrrideout/issue-899

File handles are now properly closed.
Merge pull request #901 from jrrideout/morans_i_fix

Added support for non-diagonal zeros in Moran's I.
compare_categories now respects QIIME temp dir.
Merge pull request #906 from jrrideout/r_tmp_dir

compare_categories.py now respects QIIME temp dir.