Use codecs module to open files

This prevent possible errors on open files which contains non-ASCII
characters.