Green synthesis of ZnO and Mg doped ZnO nanoparticles, and its optical properties