gitk: Clean up file encoding code and add enable/disable option