Design and fabrication of thermoelectric devices