How are wing tanks sealed around the internal wing structure?
The tanks are generally sealed with some kind of putty/resin/epoxy like material. Keep in mind that only the joints between exterior panels need to be sealed. On many aircraft this is done through inspection panels. The material is, in a manner of speaking painted/applied.  

Here is an example from a Mooney, which are pretty infamous for having in wing tanks


(source)

Tanks on larger aircraft are not all that different, much like this one off a 747


(source)

its worth noting that tanks don't need to be continuously open, they can have structures with in them as long as the fuel is free to flow around. Large and small tanks alike may very well have structural elements inside with flow holes drilled to allow fuel to move around. These elements also help reduce the effects of large quantities of fuel sloshing around as the aircraft changes attitude.