Djokovic survives Simon scare to reach quarter-finals