Variation of structural, electrical, and optical properties of Zn1−xMgxO thin films