It is not optimal, but depending on the MacBook you have, 106° C is within parameters. If it would be unsafe, the MacBook would have shutdown itself to prevent any damage.
Modern mobile CPUs can withstand temperatures of up to 115° C, and as transcoding a video in Handbrake is CPU intensive, the temperatures you experienced are normal, though you might look into better ventilating your MacBook.