add support for utf8mb4 encoding

cherry-picked utf8mb4 commit onto master.