Not sure if its helpful, but didn't see any other reply, so anyway:
Change in [1] assumes Unicode Sandwich [5] where the given content is assumed to be already encoded into utf-8 string (unicode object in py2, str object in py3, six.text_type for both py versions) and then encoded back into utf-8 bytes when its time to write it back. In your case the certificate contents was read as plain str in python 2 which is by default assumed to have ASCII encoding, so the top bread slice of the sandwich was missing and it got the jam spilling (exception).
Line of [1] is mostly for sake of python 3, where we cannot treat bytes and strs the same any more since default encoding for py3 strs is unicode and not ascii like py2. So if you remove [1] you'll probably make some problems for py3 (like comparing bytes with strings, TypeErrors, etc).