Beam coupling impedances for perforated beam pipes with general shape from impedance boundary conditions