Efficient Codes for Multilevel Flash Memories