Rewrite GeneralSFTPFile to download and cache on a per-block basis

This change allows random access reads in large files without needing to
download the whole file.  This is especially useful for streaming (with
seeks) and sshfs usage.

These changes also make the download terminate when the file handle is
closed, or when there are no pending reads.  The file is still fully
downloaded if it is written to (except for overwritten blocks).