TFT construction of RCFT correlators I: Partition functions