move network encoding functions into tools so master can use them