Encode values returned from db