If the universe is very nearly flat how can space be curved? As the WMAP and other satellite data have shown that universe is very nearly flat. But the theories like general theory of relativity assume curved space to describe gravity. So how can it be?
Does it mean that space is curved around massive bodies and the whole universe is flat. (I know we do not know the shape of the universe for sure but current data show it to be nearly flat.)
 A: 
As the WMAP and other satellite data have shown that universe is very
  nearly flat. But the theories like general theory of relativity assume
  curved space to describe gravity.

That is not correct. GR describes gravity as curved spaceTIME. The curvature of space itself is a completely different story!

Does it mean that space is curved around massive bodies and the whole
  universe is flat.

It means that the whole universe is measured to be practically flat, so you can go in any direction and will never end up where you started like you would on the 2d analogy, the surface of a 3 dimensional sphere.
Around massive bodies you have curved spaceTIME which manifests itself as acceleration (which is also a curve on the time:position-plot) while curved space alone without the time component is an analogue to a 2d surface of a 3d object.
A: A flat space is just an example of a curved space, that is, flat space-times are contained in GR inasmuch this theory describes curved space-times. Assuming that the manifold is curved does not exclude the possibility of it being flat; the latter is just a particular case of the former.
Moreover, the universe is only spatially flat at cosmological scales; locally, the curvature can be arbitrarily large.
A: Occasioned by your  comment in the previous answer: 'But we still don't know for sure that space is actually flat, right? It can have any other shape, a doughnut or a sphere?' , i would like to point out that the surface  of a 'doughnut' or a Torus in geometry is indeed flat.
So there's a difference between the terms 'flat' and 'plane'. A 'flat' space can be 'curved'. Another example is the surface of a cylinder.
Finally about the possible shapes and curvature of our universe , i am giving you the terminology as stated  in the wikipedia:

'The curvature of space is a mathematical description of whether or not the Pythagorean theorem is valid for spatial coordinates. There are three possible curvatures the universe can have:
Flat (A drawn triangle's angles add up to 180°)
Positively curved (A drawn triangle's angles add up to more than 180°)
Negatively curved (A drawn triangle's angles add up to less than 180°)'

A: Universe is a 3-dimentional.To us it's like infinity. According to researchers universe has been created some 13.4 billion years ago.So light now can reach us from 13.4 billion light years, but we don't know that it's the periphery of the universe.Its so vast that being flat is meaningless
