Updated the schematic for those that want to save an I/O pin.  There is a Hex Inverter/Buffer circuit (U1) that feeds the inputs of the Optoisolator (U2).  If you look at the wiring for the Hex Inverter you will notice that the output of the second inverter feeds the input of the first inverter.  So, when a logic 1 is placed across pin-3 it is inverted into a logic 0 which turns off the Reverse Relay.  A logic 0 is also placed at the input of the first inverter which gets converted to a logic 1 on its output and turns on the Forward Relay.

By using the inverter circuit you will no longer have the capability for dynamic breaking.  In other words, one of the relays will be active as longs as powered is applied to the circuit.  Disabling the PWM signal will keep the motor from turning.

As suggested I changed the MOSFET driver to a TLP250 and dropped the 1K resistor across the Gate to source.

Update the schematic to show that the logic grounds are isolated from the dirty motor grounds.