graph: use codecs.open. Closes #155138 [applied]