Terahertz pulse generation via optical rectification in photonic crystal microcavities