Stabilize pins on Esp8266 boot
What esp8266 module are you using? Esp01 only exposes GPIO0 and GPIO2 for you, and both of them are used during boot mode. If you use another module, like ESP12 as an example, you could use other GPIOs (4, 5, etc.) that are not read by the esp8266 during boot time, and you would not have that flickering on the relay.