Intrinsic defects and their influence on the chemical and optical properties of TiO2-x films