The following pages present a solution (provided by Timo Jokitalo) for returning to the cube shape, but not for correcting the colors.
The pages contain a table showing all 134 shapes the puzzle can be in. The shapes depict the top and bottom faces. In each case, turning along the dotted line will bring you to the next shape in the table, which can be looked up. Amazingly, you are never more than 7 twists away from position #134, which is the cube shape!
See more magic puzzles.