Phase-aligned reference-acquisition method for terahertz imaging