Controlling the dynamics of a flux qubit strongly coupled to a quantized electromagnetic field