tdb2: rework some io.c functions to encode errors in their pointer returns.