Die on a failed zwrite; don't silently ignore it

Unused return value caught by clang scan-build
Fix some undefined behavior in filter.c, caught by clang scan-build