Sergio,
If you remove the rear part of the light, you should be able to see where the connections go to on the circuit board.
I would remove the metal strip that grounds out the light unit and solder the wires directly onto the circuit board if possible.
If there isn't a hole big enough to poke the wire through, drill a hole slightly larger than your wire. Feed the wire through and then tie a knot in it before soldering the ends to the circuit board. This will prevent the soldered connections from being strained if the cable is accidentally pulled.
As you've already mentioned, it's really not a good idea to have the whole frame of the bike connected to the live terminal of your battery.
I would also cut the metal grounding strip inside the rear light so that the lighting system is completely isolated from the bikes frame.
Alan