Fix to_bytes when text is None