Better error checking in _save_netpbm