host/ports: Add missing mutex lock

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
host: Fix race in image layer handling

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
pkg/iotool: Add io tools package with a thread-safe io.Writer

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
test: Use SafeWriter to avoid races

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
host/ports: Defer mutex unlock for consistency

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
Merge pull request #645 from flynn/fix-races

Fix races