Unify writing function and properly handle control characters as noted by schwarze@---thanks!
Unify writing function and properly handle control characters as noted by
schwarze@---thanks!

kristapsdz/kcgi,kristapsdz/kcgi