Wouldn't it be easier to fix the issues with your cabling/construction??
Also, decreasing acceleration and velocity may also help.
Basically, you get racking because at least one motor is losing steps.
What exactly are the issues that are causing the racking?
If you really want to go the encoder route, you can just buy this.
http://romaxxcnc.com/encoderinterface.html