The check engine light flashes when the ECU detects knock. You may want to try and find a stock ECU and install that in place of the current ECU. I'm not exactly sure how to help you.
You may be able to use a Tactrix OBD2-USB port cable to reflash the ECU but I am not sure if that model year JDM Impreza is supported.
Good luck, other members will chime in.