Pseudo-Hermiticity of Hamiltonians under gauge-like transformation: real spectrum of non-Hermitian Hamiltonians