X-rays are like light in that they are electromagnetic waves, but they are more energetic so they can penetrate many materials to varying degrees. When the X-rays hit the film, they expose it just as light would. Since bone, fat, muscle, tumors and other masses all absorb X-rays at different levels, the image on the film lets you see different (distinct) structures inside the body because of the different levels of exposure on the film.
For more information about X-rays, check out How X-Rays Work.
Here are some interesting links: