Encode text to bytes