Move all thresholding to the threshold function.

Also support output of file directly from extract_gfc, threshold, and gfc_stats.