virtual-image: Fix race condition closing new connection
When a new connection came in we would close the old connection. This in turn would trigger a receive error causing the *new* connection to be closed from the error handler. Fix this by simply cancelling any pending transfers when a new connection comes in. Also change the error handling code to catch issues like partial writes correctly. This fixes an issue for the fprintd test where some tests were flaky.