Gerrymandering is only a symptom, and cannot be cured without tackling the underlying disease. That disease is a political culture in which politicians will do whatever it takes to win, regardless of popular sentiment. No, I have no idea how to fix that.
Set up the system so that the politician's best chance at winning comes from doing as good a job as possible. This means providing as few oppurtunities as possible to game the system.