First-principles studies of the structural and electronic properties of pyrite