Fix invalid encoding for File objects too