Astar pathfinding diagonal support


this is what the path looks like
I want it to look like this http://prntscr.com/63eo9b
while keeping diagonals when there are no blocked tiles. like this http://prntscr.com/63eon5

Sorry for the vague description