I/O between arduinos with opto coupling. Sample schematic

That circuit is fine as it goes. I would use 1K on the receiving end and 220R on the sending end.
However it might not solve any distance related problem, for that you need a differential driver and receiver. But that depends on the exact circumstances of your setup.