The third wire (usually bare metal or green) is a ground wire. This needs to be connected to a ground wire from the wall or a grounded metal junction box.
You will need to use a pull through a new three-wire electrical cable, which you would connect to a junction box in the ceiling. Never work with live wires.