Flawed characters are more interesting than vanilla heroes or heroines. Flawed characters have chinks in their armors. They do things that push the limits of black and white/right and wrong. They do things some of us wish we could, but know that while it tastes sweet going down the aftertaste is bitter. When you write flawed characters, though, remember it's easy to make those flaws so deep they turn from good to purely bad. So how do you write a great flawed character without making him/her unlikeable?
A tortured soul--the tortured soul is good at heart but his/her pains of the past have created demons. These characters will stop and help the little old lady cross the road and yet end up at the bar at night drinking and yelling profanity at the bartender. They will help the bad guys (inadvertently) because they are driven to self-destruct, but in the end their humanities always win.
Sweet, funny, endearing but doing bad things anyway--they aren't intrinsically bad people, they just do weak or bad things. Maybe they are on a journey and seek to be a better person, but they don't know how. Maybe you need another character as their reflection -- someone in the story to reflect the inner flaws and provide light or guidance for them to make changes.
Selfishly driven to what they want even though it's not right. We're all selfish to a greater or lesser degree. Flawed characters try to achieve a means to an end. They may feel a selfish desire to have something or someone, but they know in their hearts it wouldn't be good for them. They get sucked into the moment and give in based on that selfish desire.
To keep them likeable, make sure you show their inner world of thought. The motives and reasons they do what they do. Make them understandable. Show your character compassion. Reflect back on them through the prose and their inner thoughts that they are confused and misguided, but they ultimately want the right things. The drive to do right in any situation almost always redeems a flawed character.